Passing Parameters in Nested Cloud Formation templates

萝らか妹 提交于 2019-12-05 07:10:22

问题


I am calling CFT2 from CFT1 and I am passing a list of parameters.I recently came to know that we cant pass comma delimited list of parameters, so I am looking how to achieve that solution . This is my 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"
           }
        }
    }
}

The error I am getting :

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

Is there a way I can pass these values to CFT2?


回答1:


You can pass this in this way

{
"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" }
                }
            }
        }
    }
}

And then again defining the parameter KName in CFT2

{
   "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."
        }
    }
}


来源:https://stackoverflow.com/questions/32147966/passing-parameters-in-nested-cloud-formation-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!