在我的cloudformation模板中,我有一个可以为空的参数但是Fn :: Join假设一个值,这就是示例:
"Parameters": {
"ConfigureRecipe": {
"Description": "Configure recipe.",
"Type": "String"
}
"Configure": [ { "Fn::Join": [ "", [ "myChefRecipe::", { "Ref": "ConfigureRecipe" } ] ] } ]
如果ConfigureRecipe为空,Cloudfomation会将配方“myChefRecipe ::”传递给OpsWorks,并在配置启动时给出错误,因为一个好的变量是“myChefRecipe :: mysql”。我怎么能处理这个?如果ConfigureRecipe为空,可能使用AWS :: NoValue。
答案 0 :(得分:0)
也许你可以尝试一下:
"Parameters": {
"ConfigureRecipe": {
"Description": "Configure recipe.",
"Type": "String"
}
"Conditions" : {
"CreateLayerWithoutRecipie" : {"Fn::Not" : [{"Ref" : "ConfigureRecipe"}]}
},
"Layer":{
"Type":"AWS::OpsWorks::Layer",
....
....
....
"Configure": [ "Fn::If" : [ "CreateLayerWithoutRecipie", {"Ref" : "AWS::NoValue"}, { "Fn::Join": [ "", [ "myChefRecipe::", { "Ref": "ConfigureRecipe" } ] ] } ]]
}