7 thoughts on “AWS SNS to Lambda Cross Account Setup”

  1. When you are experiencing:
    “An error occurred (InvalidParameter) when calling the Subscribe operation: Invalid parameter: TopicArn”
    While subscribing Lambda function in Account B to the SNS topic in Account A.
    check if you are not using different AWS region in –topic-arn and in your default aws settings (~/.aws/config). In such a case try to run subscription command with “–region ”

    The command would looks like this:
    aws sns subscribe \
    –topic-arn “arn:aws:sns:us-east-1:5556667778:cross-account-topic” \
    –protocol “lambda” \
    –notification-endpoint “arn:aws:lambda:us-east-1:12345678901:function:cross-account-lambda-subscriber”\
    –region us-east-1

  2. Fantastic guide and a brilliant solution to a problem I was scratching my head over for too long. Much appreciated for sharing your wisdom on this.

  3. Hi,

    How does your topic arn:aws:sns:us-east-1:5556667778:cross-account-topic”looks like?
    I converted your code to cloudformation like

    LambdaSNS:
    Type: “AWS::SNS::Topic”

    this topic is a target for an eventrule, unf i do not see the lambda triggered ..

    if i’m trying to setup cloudformation in account A like

    LambdaSNS:
    Type: “AWS::SNS::Topic”
    Subscription:
    – Endpoint: “arn:aws:lambda-Account B”
    Protocol: “lambda”
    the resource can’t be created because of an error stating you are not the owner of the endpoint

  4. Should be possible. You’ll need to look up how to add a resource based policy using Serverless. If its not feature of SLS, then you should at least be able to use the serverless hooks or plugins system to at least do it by running aws cli as part of the sls deploy command lifecycle.

  5. I think it is a crime to leave such a wonderful guide without a comment. Works perfectly and nice code examples, helped me a lot.

Leave a Comment