'Can you nest "Fn::FindInMap" inside "Fn::Sub"?
I'm doing this:
{"Fn::Join": [":", [
"arn:aws:sns",
{ "Ref": "AWS::Region"},
{ "Ref": "AWS::AccountId"},
{"Fn::FindInMap" : [ "config", "mytopic", { "Ref" : "deployment" } ] }
]]
But I would prefer to use SUB like this but it's not valid JSON:
{"Fn::Sub" : "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${"Fn::FindInMap" : [ "config", "mytopic", { "Ref" : "deployment" } ] }"}
Solution 1:[1]
You can't call Fn::FindInMap directly from the Fn::Sub template. Only a limited number of expressions work OOTB.
Instead you can pass additional variables to Fn::Sub. For example:
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'
Here, I calculate some value and pass it as EmptyVideoverarbeitungClusterAlarmFunction_Arn variable to Sub.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | lexicore |
