我正在这样做:
{"Fn::Join": [":", [
"arn:aws:sns",
{ "Ref": "AWS::Region"},
{ "Ref": "AWS::AccountId"},
{"Fn::FindInMap" : [ "config", "mytopic", { "Ref" : "deployment" } ] }
]]
但我更喜欢像这样使用 SUB 但它不是有效的 JSON:
{"Fn::Sub" : "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${"Fn::FindInMap" : [ "config", "mytopic", { "Ref" : "deployment" } ] }"}
最佳答案
您无法直接从 Fn::Sub
模板调用 Fn::FindInMap
。 Only a limited number of expressions work OOTB.
相反,您可以将其他变量传递给 Fn::Sub
。例如:
DefinitionString: !Sub
- |-
{
"Comment":"Extract metadata and anonymize the videoclip",
"StartAt":"ExtractMetadataAndAnonymize",
"States":{
"ExtractMetadataAndAnonymize":{
"Type":"Parallel",
"Next":"LogResult",
"Branches":[
{
"StartAt":"AlarmIfVideoverarbeitungClusterIsEmpty",
"States":{
"AlarmIfVideoverarbeitungClusterIsEmpty":{
"Type":"Task",
"Resource":"${EmptyVideoverarbeitungClusterAlarmFunction_Arn}",
....
}
}
}
- EmptyVideoverarbeitungClusterAlarmFunction_Arn: !ImportValue
'Fn::Sub': 'stk-${EnvType}-${EnvId}-videoverarbeitung-cluster-EmptyVideoverarbeitungClusterAlarmFunction-Arn'
在这里,我计算一些值并将其作为 EmptyVideoverarbeitungClusterAlarmFunction_Arn
变量传递给 Sub
。
关于amazon-web-services - 您可以将 "Fn::FindInMap"嵌套在 "Fn::Sub"中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58986248/