'Value of property VPCZoneIdentifier must be of type List of String

"wordpressASG": {
      "Type": "AWS::AutoScaling::AutoScalingGroup",
      "Properties": {
        "AvailabilityZones": [
          "ap-southeast-2a",
          "ap-southeast-2b"
        ],
        "VPCZoneIdentifier": [
          {
            "ref": "subnetA"
          },
          {
            "ref": "subnetB"
          }
        ],
        "MinSize": "0",
        "HealthCheckGracePeriod": 300,
        "MaxSize": "0",
        "Cooldown": "300",
        "LaunchTemplate": {
          "LaunchTemplateId": {
            "Ref": "wordpressTemplate"
          },
          "Version": {
            "Fn::GetAtt": [
              "wordpressTemplate",
              "LatestVersionNumber"
            ]
          }
        },
        "MetricsCollection": [
          {
            "Granularity": "1Minute",
            "Metrics": [
              "GroupMinSize",
              "GroupMaxSize"
            ]
          }
        ],
        "TargetGroupARNs": [
          {
            "Ref": "wordpressTG"
          }
        ]
      }
    }

Probably not a new question, but all examples are of using a subnet parameter. List needs to be string, but ref Should give strings for this thing. The Subnets are being created in the same script.



Solution 1:[1]

To be honest for your parameter use List<AWS::EC2::Subnet::Id> and then just use the value of that rather than trying to use individual subnets in your list.

More parameters: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

Solution 2:[2]

In YAML format

VPCZoneIdentifier: !Split [',', !Ref Subnets]

Define Subnets as a String parameter and pass in like:

ParameterKey=Subnets,ParameterValue=\"subnet-0d...d5,subnet-01...03\"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chris Williams
Solution 2 SVUser