Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In `aws cloudformation deploy --parameter-overrides`, how to pass multiple values to `List<AWS::EC2::Subnet::ID>` parameter?

I am using this CloudFormation template

The List parameter I'm trying to pass values to is:

"Subnets" : {
  "Type" : "List<AWS::EC2::Subnet::Id>",
  "Description" : "The list of SubnetIds in your Virtual Private Cloud (VPC)",
  "ConstraintDescription" : "must be a list of at least two existing subnets associated with at least two different availability zones. They should be residing in the selected Virtual Private Cloud."
},

I've written an utility script that looks like this:

#!/bin/bash
SUBNET1=subnet-abcdef
SUBNET2=subnet-ghijlm
echo -e "\n==Deploying stack.cf.yaml===\n"
aws cloudformation deploy \
  --region $REGION \
  --profile $CLI_PROFILE \
  --stack-name $STACK_NAME \
  --template-file stack.cf.json \
  --no-fail-on-empty-changeset \
  --capabilities CAPABILITY_NAMED_IAM \
  --parameter-overrides \
    VpcId=$VPC_ID \
    Subnets="$SUBNET1 $SUBNET2" \ #<---------------this fails
    InstanceType=$EC2_INSTANCE_TYPE \
    OperatorEMail=$OPERATOR_EMAIL \
    KeyName=$KEY_NAME \

If I deploy this, after a while my stack fails to deploy saying that a Subnet with the value "subnet-abcdef subnet-ghijlmn" does not exist.


1 Answers

The correct way to pass parameters to list is to comma separate them

So:

#!/bin/bash
SUBNET1=subnet-abcdef
SUBNET2=subnet-ghijlm
aws cloudformation deploy --parameter-overrides Subnets="$SUBNET1,SUBNET2"

will work


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!