Amazon web services 将值传递给嵌套堆栈
使用嵌套堆栈创建堆栈时遇到问题。我有一个主模板(列出的模板用于测试,并且只引用一个嵌套堆栈)。我试图找出如何将值从主堆栈传递到嵌套堆栈,或者有更好的方法来实现这一点吗?每次尝试创建堆栈时,我都会得到:Amazon web services 将值传递给嵌套堆栈,amazon-web-services,nested,amazon-cloudformation,Amazon Web Services,Nested,Amazon Cloudformation,使用嵌套堆栈创建堆栈时遇到问题。我有一个主模板(列出的模板用于测试,并且只引用一个嵌套堆栈)。我试图找出如何将值从主堆栈传递到嵌套堆栈,或者有更好的方法来实现这一点吗?每次尝试创建堆栈时,我都会得到: Template format error: Unresolved resource dependencies [VpcCidrBlock] in the Resources block of the template. 我理解这意味着我放在主堆栈中的参数没有传递到嵌套堆栈 主模板: {
Template format error: Unresolved resource dependencies [VpcCidrBlock] in the Resources block of the 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"
}
}
}
}
}
}
{
"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"
}
}
]
}
}
}
}
专有网络模板:
{
"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"
}
}
}
}
}
}
{
"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"
}
}
]
}
}
}
}
谢谢 您的内部模板需要输入参数:
"Parameters" : {
"VpcCidrBlock" : {
"Description" : "VPC CIDR Block.",
"Type" : "String"
}
},
就像您的外部“包装器”模板一样。您的内部模板需要一个输入参数:
"Parameters" : {
"VpcCidrBlock" : {
"Description" : "VPC CIDR Block.",
"Type" : "String"
}
},
就像您的外部“包装器”模板一样