我遇到的情况是,我将应用程序部署在不同的环境(产品和阶段)中。 我有一个带有以下参数的通用 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 来说它应该是 Major ,对于 stage 来说它应该是 secondary 。
我应该如何配置它
最佳答案
我认为,与其将 Fn::Join
包装在 Fn::If
内,反之亦然更好。这应该可以正常工作:
{
"AlarmName":
{"Fn::Join": ["",
[{"Ref" : "AppId"},
",",
{"Ref" : "AppServerAG"},
":",
"HealthCheck",
",",
{"Fn::If": ["CreateProdResources", "MAJOR", "MINOR"]}
]
]}
}
关于amazon-web-services - 我可以将 fn::join 放在 cftemplate 形成中的 fn::if 语句内吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54307065/