在嵌套云形成模板中传递参数

Passing Parameters in Nested Cloud Formation templates

我正在从 CFT1 调用 CFT2,我正在传递 parameters.I 的列表,最近发现我们无法传递以逗号分隔的参数列表,所以我正在寻找如何实现该解决方案。这是我的 CFT1:

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Top Stack",
   "Resources": {
   "ChildStack01": {
           "Type" : "AWS::CloudFormation::Stack",
           "Properties" : {
               "TemplateURL": "https://s3.amazonaws.com/tbdchef/frontend1.json",
               "Parameters": {
                "AvailabilityZone1a": {
                    "Default": "us-east-1a",
                    "Description": "us-east-1a",
                    "Type": "String"
                },
                "AvailabilityZone1b": {
                    "Default": "us-east-1b",
                    "Description": "us-east-1b",
                    "Type": "String"
                },
                "ChefDevSNSTopic": {
                    "Description": "ARNforSNSTopic",
                    "Type": "String",
                    "Default": "arn:aws:sns:us-east-1:093937234853:Enterprise_Monitoring_SNS_Horizontal"
                }
               },
              "TimeoutInMinutes" : "5"
           }
        }
    }
}

我得到的错误:

Value of property Parameters must be an object with String (or simple type) properties

有什么方法可以将这些值传递给 CFT2?

你可以这样传递

{
"AWSTemplateFormatVersion": "2010-09-09",
    "Parameters": {
        "KeyName": {
            "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
            "Type": "AWS::EC2::KeyPair::KeyName",
            "ConstraintDescription": "must be the name of an existing EC2 KeyPair."
        },
    },
    "Resources": {
        "ChildStack01": {
           "Type" : "AWS::CloudFormation::Stack",
           "Properties" : {
               "TemplateURL": "https://s3.amazonaws.com/tbdchef/frontend1.json",
               "Parameters": {
                         "KName":  { "Ref" : "KeyName" }
                }
            }
        }
    }
}

然后在CFT2中再次定义参数KName

{
   "AWSTemplateFormatVersion": "2010-09-09",
   "Parameters": {
        "KName": {
            "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
            "Type": "AWS::EC2::KeyPair::KeyName",
            "ConstraintDescription": "must be the name of an existing EC2 KeyPair."
        }
    }
}