【问题标题】:Cannot pass a list of Subnet IDs as parameter无法将子网 ID 列表作为参数传递
【发布时间】:2018-03-30 09:12:36
【问题描述】:

我正在尝试将子网 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文件中的参数sn-p:

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

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

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    我知道这个线程已经有一年了,我假设您使用 aws cli 创建堆栈,但我遇到了同样的问题,最后偶然发现了答案。在应得的地方给予信用: https://github.com/aws/aws-cli/issues/2478#issuecomment-427167512

    用反斜杠转义“,”,它将解决问题。在我的情况下,这是一个 jekins 的工作,所以我不得不加倍反斜杠:

      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"
    

    【讨论】:

      【解决方案2】:

      您应该使用逗号分隔的要包含的子网 ID 列表指定 ParameterValue,不带空格。请参阅此处“列表”下的部分: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-20
        • 1970-01-01
        • 1970-01-01
        • 2013-01-24
        相关资源
        最近更新 更多