【问题标题】:Adding a list to the parameters file for Cloudformation template将列表添加到 Cloudformation 模板的参数文件
【发布时间】:2019-11-14 10:32:10
【问题描述】:

我有一个 cloudformation 模板,我在其中发送一个 JSON 参数文件。这不是一个真正的问题,因为我的参数文件曾经看起来像这样:

[
    "InstanceType=t2.medium",
    "AmiStack=amilookup-stack"
]

但是,我想在参数文件中添加一个列表,如下所示:

[
    "InstanceType=t2.medium",
    "AmiStack=amilookup-stack",
    [
        "CertificateArn1=arn:aws:acm:us-east-1:xxx",
        "CertificateArn2=arn:aws:acm:us-east-1:xxy",
    ]
]

在我的参数 json 文件中表达这一点的最佳方式是什么,以及如何在 cloudformation 模板本身中表达这一点?enter code here

【问题讨论】:

    标签: json amazon-web-services parameters yaml amazon-cloudformation


    【解决方案1】:

    这是使用 Cloudformation 的 known problem。您可以使用comma demlimited list 作为参数类型。

    Cloudformation 模板 (test.json)

     {
      "AWSTemplateFormatVersion": "2010-09-09",
      "Parameters": {
        "Name": {
          "Type": "String",
          "Description": "SubnetGroup Name"
        },
        "Subnets": {
          "Type": "CommaDelimitedList",
          "Description": "The list of SubnetIds in your Virtual Private Cloud (VPC)"
        }
      },
      "Resources": {
        "myDBSubnetGroup": {
          "Type": "AWS::RDS::DBSubnetGroup",
          "Properties": {
            "DBSubnetGroupDescription": "description",
            "DBSubnetGroupName": {
              "Ref": "Name"
            },
            "SubnetIds": {
              "Ref": "Subnets"
            }
          }
        }
      }
    }
    

    Parameter.json

    [
      {
        "ParameterKey": "Name",
        "ParameterValue": "testName"
      },
      {
        "ParameterKey": "Subnets",
        "ParameterValue": "subnet-abcdefg,subnet-abcdef1,subnet-abcdef2"
      }
    ]
    
    
    aws cloudformation create-stack --stack-name testStack --template-body file://test.json --parameters file://parameter.json --profile yourawsprofile
    

    【讨论】:

    • 我将您描述的格式的证书添加到我的原始 json 文件中,但现在我收到 jq: error (at xxxxxx.json:21): split input and separator must be strings跨度>
    • 不确定我是否明白你的问题。我认为请提供详细信息以重现该问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-12
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多