我从 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/