我遇到的情况是,我的应用程序部署在不同的环境(产品和阶段)中。 我有一个带有以下参数的通用cftemplate.json
"Parameters" : {
"EnvType" : {
"Description" : "Environment type.",
"Default" : "test",
"Type" : "String",
"AllowedValues" : ["prod", "stage"],
"ConstraintDescription" : "must specify prod or test."
}
},
"Conditions" : {
"CreateProdResources" : {"Fn::Equals" : [{"Ref" : "EnvType"}, "prod"]}
},
现在我有警报了,
"AppServerHealthCheckAlarm":{
"Type":"AWS::CloudWatch::Alarm",
"Properties":{
"AlarmName" : {"Fn::Join" : ["", [
{"Ref" : "AppId"}, ",",
{"Ref" : "AppServerAG"}, ":", "HealthCheck", ",", "MAJOR"]]},
------
------
------
}
},
现在,我想将此fn :: join放在fn :: if条件内,以便于prod应该是主要的,对于stage应该是minor的。
我应该如何配置
答案 0 :(得分:0)
我认为与其将Fn::Join
包装在Fn::If
内,反而更好。这应该可以正常工作:
{
"AlarmName":
{"Fn::Join": ["",
[{"Ref" : "AppId"},
",",
{"Ref" : "AppServerAG"},
":",
"HealthCheck",
",",
{"Fn::If": ["CreateProdResources", "MAJOR", "MINOR"]}
]
]}
}