I have the follow sam template for a lambda that would call two SNS fifo:
Resources:
MainFunction:
Type: 'AWS::Serverless::Function'
Properties:
Handler: core.lambda_function.lambda_handler
Policies:
- SNSPublishMessagePolicy:
TopicName: !Select [ 5, !Split [ ":", !Ref SNSTopicARN ] ]
- SNSPublishMessagePolicy:
TopicName: !Select [ 5, !Split [ ":", !Ref SNSTopicARN2 ] ]
But when SNSTopicARN and SNSTopicARN2 has a ARN with different userId it creates wrong resource like in SNSTopic2 is created something like:
{
"Statement": [
{
"Action": [
"sns:Publish"
],
"Resource": "arn:aws:sns:us-east-1:idAccountFromSNS1:SNS2.fifo",
"Effect": "Allow"
}
]
}
So ids would be mixed up. is there some way to specify ARN in SNSPublishMessagePolicy or use another approach to avoid this ?
From https://repost.aws/knowledge-center/lambda-sam-template-permissions:
so you should be able to add something to the policies that looks like this: