1

I am trying to use cloudformation to setup a ASG and I have a target group which I would like to associate with the ASG. The target group is created okay but when I go to attach it to the ASG I get an error message. I'd like to be able to attach this as I want a ALB in front of the ASG

Error message:

Value of property TargetGroupARNs must be of type List of String

Cloudformation code

TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      VpcId: 
        Fn::ImportValue: 
          !Sub "${Prefix}-VpcId"
      TargetType: instance
      Port: 443
      Protocol: HTTPS
AutoScalingGroup:
    Type: AWS::AutoScaling::AutoScalingGroup
    Properties:
      AutoScalingGroupName: Autoscaling Group Alpha
      Cooldown: 120
      DesiredCapacity: 1
      LaunchConfigurationName: AlphaLaunchConfiguration
      MaxSize: 1
      MinSize: 1
      Tags:
        - 
          Key: Name
          Value: Alpha ASG
          PropagateAtLaunch: 'true'
      TargetGroupARNs:
        Ref: TargetGroup
1
  • Did you solve the issue? It seems that TargetGroupARNs is neither a List or String.
    – 030
    Commented Dec 20, 2019 at 11:42

2 Answers 2

2
Resources:                                                                                                                                                                                  
    TargetGroup:                                                                                                                                                                              
        Type: AWS::ElasticLoadBalancingV2::TargetGroup                                                                                                                                        
        Properties:                                                                                                                                                                           
          VpcId:                                                                                                                                                                              
            Fn::ImportValue:                                                                                                                                                                  
              !Sub "${Prefix}-VpcId"                                                                                                                                                          
          TargetType: instance                                                                                                                                                                
          Port: 443                                                                                                                                                                           
          Protocol: HTTPS                                                                                                                                                                     
    AutoScalingGroup:                                                                                                                                                                         
        Type: AWS::AutoScaling::AutoScalingGroup                                                                                                                                              
        Properties:                                                                                                                                                                           
          AutoScalingGroupName: Autoscaling Group Alpha                                                                                                                                       
          Cooldown: "120"                                                                                                                                                                     
          DesiredCapacity: "1"                                                                                                                                                                
          LaunchConfigurationName: AlphaLaunchConfiguration                                                                                                                                   
          MaxSize: "1"                                                                                                                                                                        
          MinSize: "1"                                                                                                                                                                        
          Tags:                                                                                                                                                                               
            -                                                                                                                                                                                 
              Key: Name                                                                                                                                                                       
              Value: Alpha ASG                                                                                                                                                                
              PropagateAtLaunch: true                                                                                                                                                         
          TargetGroupARNs:                                                                                                                                                                    
            - Ref: TargetGroup

As the error message states, TargetGroupARNs value should be of type List. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html#cfn-as-group-targetgrouparns

0

Changing the value of "TargetGroupARNs:" from "Ref: TargetGroup" to "- !Ref TargetGroup" should solve the problem.

Reference :https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.