[英]AWS cloudformation pass value to nested stack
I'm having trouble creating stacks using nested stacks. 我在使用嵌套堆栈创建堆栈时遇到了麻烦。 I have one master template (the one listed is for testing, and is only reference one nested stack).
我有一个主模板(列出的一个用于测试,并且仅引用一个嵌套堆栈)。 I am trying to figure out how to pass a value from the master to the nested stack, or is there a better way to do this?
我试图弄清楚如何将值从母版传递到嵌套堆栈,还是有更好的方法呢? Every time try to create the stack, I get a:
每次尝试创建堆栈时,我都会得到:
Template format error: Unresolved resource dependencies [VpcCidrBlock] in the Resources block of the template.
Which I understand means the parameter I put in the master stack is not getting passed to the nested stack. 据我了解,这意味着我放入主堆栈中的参数没有传递给嵌套堆栈。
Master Template: 主模板:
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Master template",
"Parameters" : {
"availabilityZone" : {
"Default" : "us-east-1d",
"Description" : "Enter AvailabilityZone.",
"Type" : "String"
},
"VpcCidrBlock" : {
"Default" : "10.0.0.0/16",
"Description" : "VPC CIDR Block.",
"Type" : "String"
}
},
"Resources" : {
"VPCStack" : {
"Type" : "AWS::CloudFormation::Stack",
"Properties" : {
"TemplateURL" : "https://s3.amazonaws.com/dev.url.templates/templates/vpcStack.json",
"TimeoutInMinutes" : "5",
"Parameters" : {
"VpcCidrBlock" : {
"Ref" : "VpcCidrBlock"
}
}
}
}
}
}
VPC Template: VPC模板:
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "VPC template",
"Resources" : {
"VpcStack" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"EnableDnsSupport" : "true",
"EnableDnsHostnames" : "true",
"CidrBlock" : {
"Ref" : "VpcCidrBlock"
},
"Tags" : [
{
"Key" : "Application",
"Value" : {
"Ref" : "AWS::StackName"
}
}
]
}
}
}
}
Thanks! 谢谢!
Your internal template needs an input parameter: 您的内部模板需要一个输入参数:
"Parameters" : {
"VpcCidrBlock" : {
"Description" : "VPC CIDR Block.",
"Type" : "String"
}
},
Just like your outer "wrapper" template. 就像您的外部“包装”模板一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.