amazon-web-services - 在嵌套云形成模板中传递参数

标签 amazon-web-services aws-cloudformation

我从 CFT1 调用 CFT2,并且传递参数列表。我最近发现我们无法传递逗号分隔的参数列表,所以我正在寻找如何实现该解决方案。这是我的 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."
        }
    }
}

关于amazon-web-services - 在嵌套云形成模板中传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32147966/

相关文章:

amazon-web-services - 使用 Import 和 sub psudo 函数返回错误

shell - Cloudformation 无法识别 UserData 脚本中的 Shell 变量

amazon-web-services - 如何在 Cognito 中启用自定义注册和登录行为

Swift AWS Cognito 错误 : Authentication delegate not set

ssl - 如何绕过 Amazon 负载均衡器以终止对我的自动扩展组实例的 https 访问?

amazon-web-services - 无法在 Web 浏览器上使用 AWS 公共(public) DNS 打开 cloudera manager 7180 端口

amazon-web-services - AWS ECS - 无法在 cloudformation 模板中指定服务名称

amazon-web-services - 如何使用 cloudformation 创建具有 s3 权限的 IAM 用户?

amazon-web-services - AWS Quicksight : How do you update the data in a file upload data source

json - 是否可以使用 AWS Cloudformation 模板将 Loadbalancers DNSname 连接到 Route53?