Invoking AWS SNS using Amazon lambda from Different Accounts?

494 views Asked by At

I have two AWS accounts, Account 1 has lambda, and Account 2 has an SNS which will trigger a lambda function in the same account.

Now I want to trigger the SNS in Account 2 from the lambda function in Account 1. I'm not sure how to create a trust relationship between those accounts for the respective services.

Any lead is highly appreciated.

1

There are 1 answers

0
Marcin On

One way to do that would be:

Account B (with SNS topic)

Add the following statement to SNS topic policy:

    {
      "Sid": "__console_pub_0",
      "Effect": "Allow",
      "Principal": {
        "AWS": "<ID-ACCOUNT-A>"
      },
      "Action": "SNS:Publish",
      "Resource": "<ARN-OF-THE-SNS-TOPIC>"
    }

Account A (with lambda)

Add the following statement to lambda execution role:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "sns:Publish",
            "Resource": "<ARN-OF-SNS-TOPIC-FROM-ACCOUNT-A>"
        }
    ]
}