更多AWS問題!好的,所以這個想法是一個主模板調用所有的嵌套堆棧。在這裏的幫助下,我想出瞭如何將主參數傳遞給嵌套堆棧。現在我正試圖弄清楚如何將嵌套堆棧中的值傳遞給嵌套堆棧。我相信這應該通過出口和進口完成,但我認爲我沒有這樣做是正確的。我不確定是否我的進口或出口是錯誤的。AWS CloudFormation:在嵌套堆棧之間傳遞值
我得到的錯誤是:
No export named TestStack1-VpcStackID found. Rollback requested by user.
站長:
{
"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"
},
"PublicSubnetCidrBlock" : {
"Default" : "10.0.0.0/24",
"Description" : "Public subnet CIDR block.",
"Type" : "String"
}
},
"Resources" : {
"VpcStack" : {
"Type" : "AWS::CloudFormation::Stack",
"Properties" : {
"Parameters" : {
"VpcCidrBlock" : {
"Ref" : "VpcCidrBlock"
}
},
"TemplateURL" : "https://s3.amazonaws.com/url/templates/vpcStack.json",
"TimeoutInMinutes" : "5"
}
},
"PublicRouteStack" : {
"Type" : "AWS::CloudFormation::Stack",
"Properties" : {
"Parameters" : {
"PublicSubnetCidrBlock" : {
"Ref" : "PublicSubnetCidrBlock"
},
"VpcStack" : {
"Fn::ImportValue" : {
"Fn::Sub" : "${AWS::StackName}-VpcStackID"
}
}
},
"TemplateURL" : "https://s3.amazonaws.com/url/templates/publicRouteStack.json",
"TimeoutInMinutes" : "5"
}
}
}
}
VpcStack(嵌套 - 我不認爲我在輸出右):
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "VPC template",
"Parameters" : {
"VpcCidrBlock" : {
"Description" : "Vpc CIDR Block.",
"Type" : "String"
}
},
"Resources" : {
"VpcStack" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"EnableDnsSupport" : "true",
"EnableDnsHostnames" : "true",
"CidrBlock" : {
"Ref" : "VpcCidrBlock"
},
"Tags" : [
{
"Key" : "Application",
"Value" : {
"Ref" : "AWS::StackName"
}
}
]
}
}
},
"Outputs" : {
"VpcStack" : {
"Description" : "VPC Stack ID.",
"Value" : {
"Ref" : "VpcStack"
},
"Export" : {
"Name" : {
"Fn::Sub" : "${AWS::StackName}-VpcStackID"
}
}
}
}
}
PublicStubnetStack(我認爲這是它失敗):
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Public Subnet Stack",
"Parameters" : {
"PublicSubnetCidrBlock" : {
"Default" : "10.0.0.0/24",
"Description" : "Public subnet CIDR block.",
"Type" : "String"
},
"VpcStack" : {
"Description" : "VPC Stack.",
"Type" : "String"
}
},
"Resources" : {
"PublicSubnet" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : {
"Ref" : "VpcStack"
},
"CidrBlock" : {
"Ref" : "PublicSubnetCidrBlock"
},
"Tags" : [
{
"Key" : "Application",
"Value" : {
"Ref" : "AWS::StackName"
}
},
{
" Key" : "Network",
"Value" : "Public"
}
]
}
}
},
"Outputs" : {
"PublicSubnet" : {
"Description" : "Public Subnet ID.",
"Value" : {
"Ref" : "PublicSubnet"
},
"Export" : {
"Name" : {
"Fn::Sub" : "${AWS::StackName}-PublicSubnetID"
}
}
}
}
}
對不起張貼這麼多,我很新的AWS,並正在試圖快速把它撿起來。