Search code examples
listaws-cloudformationdefault

CloudFormation - set multiple default values for type of List<>


When I'm creating CloudFormation template with the use of interactive Parameters, I can define the type of List<> to be able to select multiple values, for example:

SubnetIds:
  Type: List<AWS::EC2::Subnet::Id>
  Description: Select multiple subnets from selected VPC.
  Default: "????"

or:

SecurityGroups:
  Type: List<AWS::EC2::SecurityGroup::Id>
  Description: Select security groups.
  Default: "???"

The question is how do I pre-set default value with multiple selections? if default takes only the string instead of a list, and string with commas between multiple values also doesn't help

Any ideas? please, hint me


Solution

  • I recently run in the same issue. The answer is simple - there should be no spaces in your comma-separated list. So it would look like:

    SecurityGroups:
      Type: List<AWS::EC2::SecurityGroup::Id>
      Description: Select security groups.
      Default: "sg-11111111,sg-22222222"
    

    And this way the values would be preselected in your template.

    P.S. Do not try CommaDelimitedList or so - it won't work in the way you want. The string values would be selected, but not the actual security groups.

    Source: https://forums.aws.amazon.com/thread.jspa?threadID=165144