Reputation: 353
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:
{
"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!
Upvotes: 0
Views: 1738
Reputation: 36073
Your internal template needs an input parameter:
"Parameters" : {
"VpcCidrBlock" : {
"Description" : "VPC CIDR Block.",
"Type" : "String"
}
},
Just like your outer "wrapper" template.
Upvotes: 2