微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在`aws cloudformation deploy --parameter-overrides`中,如何将多个值传递给`List<AWS::EC2::Subnet::ID>`参数?

如何解决在`aws cloudformation deploy --parameter-overrides`中,如何将多个值传递给`List<AWS::EC2::Subnet::ID>`参数?

我正在使用 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”的子网不存在。

解决方法

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

所以:

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

会起作用

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。