无法将子网ID列表作为参数

时间:2017-10-18 13:16:51

标签: amazon-web-services amazon-cloudformation

我正在尝试将子网ID列表传递给云形成模板,但是我收到了错误消息。我做错了什么?

模板中的参数:

  ClusterSubnets:
    Description: Subnets, in the same VPC where cluster ec2 instances reside.
                Typically private.  Use mutiples, each in a different AZ for HA.
    Type: "List<AWS::EC2::Subnet::Id>"

来自json文件的参数片段:

  {
    "ParameterKey": "ClusterSubnets",
    "ParameterValue": [ "subnet-8fc8c4f7" ]
  },

结果: 参数验证失败: 参数参数[1]的参数类型无效.ParameterValue,值:[u'subnet-8fc8c4f7'],类型:类型'列表',有效类型:类型'basestring'

2 个答案:

答案 0 :(得分:1)

我知道这个线程已经使用了一年,我假设您正在使用aws cli创建堆栈,但是我遇到了同样的问题,并最终迷失了答案。给予应有的信誉: https://github.com/aws/aws-cli/issues/2478#issuecomment-427167512

使用反斜杠转义“,”,它将解决此问题。就我而言,这是一项杰金斯工作,所以我不得不加倍反斜杠:

  sh "aws cloudformation create-stack  --template-url ${TEMPLATE} \
      --stack-name $NAME \
      --capabilities CAPABILITY_IAM \
      --parameters ParameterKey=SecurityGroups,ParameterValue=\"$SG_GROUP2\\,$SG_GROUP1\"; \
  aws cloudformation wait stack-create-complete --stack-name $CLUSTER_NAME"

答案 1 :(得分:0)

您应使用逗号分隔的子网ID列表指定ParameterValue,不包含空格。请参阅&#34;列表&#34;下的部分;这里: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

相关问题