Resolve "Id must be a String" in CloudFormation Template error

Viewed 22

The following is in the Resources Section of my CloudFormation Template:

  myAlbTargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      HealthCheckPath: /
      HealthCheckIntervalSeconds: 10
      HealthCheckTimeoutSeconds: 5
      HealthyThresholdCount: 2
      Matcher:
        HttpCode: 200,302
      Name: myWebServer
      Protocol: HTTP
      Port: 80
      Targets:
        - Id: Fn::ImportValue: myVPC-myWebServer1
          Port: 80
        - Id: Fn::ImportValue: myVPC-myWebServer2
          Port: 80
      TargetType: instance
      UnhealthyThresholdCount: 5
      VpcId:
        Fn::ImportValue: myVPC

When I load the Template I get an error indicating "Id must be a String" for Targets.

Per another thread I read, I've wrapped the value in quotes, and also tried to use !Sub, but to no avail.

Does anyone know how to resolve this issue? I've been through the Docs, but I'm obviously missing something (probably basic).

Thanks in advance for any guidance!

1 Answers

This has been resolved. It was an alignment / formatting issue. I'll post the proper format here for anyone that might be interested.

      Targets:
        - Id: 
            Fn::ImportValue: 
             !Sub 'myVPC-myWebServer1'
          Port: 80
        - Id: 
            Fn::ImportValue:
             !Sub 'myVPC-myWebServer2'
          Port: 80
Related