CloudFormation-可能具有嵌套映射? [英] CloudFormation -- possible to have nested Mappings?
本文介绍了CloudFormation-可能具有嵌套映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以像下面的示例一样在CloudFormation中嵌套映射?
Is it possible to have nested Mappings in CloudFormation, like the following example?
"Mappings" :
{
"Regions" :
{
"us-east-1" :
{
"Environments" :
{
"dev" :
{
"ImageId" : "something",
"Subnet" : "something"
},
"qa" :
{
"ImageId" : "something",
"Subnet" : "something"
}
}
},
"us-west-2" :
{
"Environments" :
{
"dev" :
{
"ImageId" : "something",
"Subnet" : "something"
},
"qa" :
{
"ImageId" : "something",
"Subnet" : "something"
}
}
}
}
}
当我尝试执行此类操作时,出现以下错误:
When I attempt to do something like this, I get the following error:
模板格式错误:每个Mappings属性必须为字符串或列表。
Template format error: Every Mappings attribute must be a String or a List.
如果嵌套映射不可能,那么在需要两个参数选择的CFT中存储值的最佳方法是什么(例如,取决于两个区域和环境的值)?
If nested Mappings aren't possible, then what is the best way to store values in a CFT that require two parameters to select (such as values that depend on BOTH Region and environment)?
推荐答案
类似这样的东西:
"ImageMap" : {
"us-east-1" : { "dev" : "ami-11111111", "qa" : "ami-22222222" },
"us-west-1" : { "dev" : "ami-33333333", "qa" : "ami-44444444" }
}
然后访问这些值:
"Value" : {
"Fn::FindInMap" : [
"ImageMap", { "Ref" : "AWS::Region" }, { "Ref" : "EnvironmentType" }
]
}
这篇关于CloudFormation-可能具有嵌套映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文