【问题标题】:In `aws cloudformation deploy --parameter-overrides`, how to pass multiple values to `List<AWS::EC2::Subnet::ID>` parameter?在`aws cloudformation deploy --parameter-overrides`中,如何将多个值传递给`List<AWS::EC2::Subnet::ID>`参数?
【发布时间】:2021-07-24 13:55:24
【问题描述】:

我正在使用this CloudFormation template

我试图将值传递给的 List 参数是:

"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."
},

我编写了一个如下所示的实用程序脚本:

#!/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 \

如果我部署它,一段时间后我的堆栈无法部署,说不存在值为“subnet-abcdef subnet-ghijlmn”的子网。

【问题讨论】:

    标签: amazon-cloudformation aws-cli


    【解决方案1】:

    将参数传递给列表的正确方法是用逗号分隔它们

    所以:

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

    会起作用

    【讨论】:

      猜你喜欢
      • 2017-09-09
      • 1970-01-01
      • 1970-01-01
      • 2019-09-16
      • 1970-01-01
      • 1970-01-01
      • 2021-03-27
      • 2020-06-10
      • 1970-01-01
      相关资源
      最近更新 更多