question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[sns] Lambda function in different region subscription error

See original GitHub issue

I had this working before in previous CDK version. However, not working in recent CDK version. I have a lambda function in ap-southeast-2 region, I am trying to add that lambda function in the sns topic subscriber in us-east-1 region. From the AWS console, I can find the function arn and make it as sns subscriber, however not from cdk.

Reproduction Steps

Lambda function imported

const snsSubscriberLambda = lambda.Function.fromFunctionArn( this, “snsSubsciberLambda”, “arn:aws:lambda:ap-southeast-2:XXXXXXX:function:XXXX” ); // add snsSubsciberLambda as topic subscriber topic.addSubscription( new subscription.LambdaSubscription(snsSubscriberLambda) );

This will result in error like the following: Functions from ‘ap-southeast-2’ are not reachable in this region (‘us-east-1’) (Service: AWSLambda; Status Code: 404; Error Code: ResourceNotFoundException; Request ID: XXXXXXX; Proxy: null)

What did you expect to happen?

There should be no error creating a subscription for lambda function in other region.

What actually happened?

Permission error occurred.

snsSubsciberLambda/AllowInvoke:XXXXXXX

Environment

  • CLI Version :1.68.0
  • Framework Version:
  • Node.js Version:v12.14.1
  • OS :Windows
  • Language (Version):TypeScript (4.0.3)

Other


This is 🐛 Bug Report

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:7

github_iconTop GitHub Comments

1reaction
alexb-ukcommented, Oct 28, 2020

I’m running 1.70.0 and am also seeing this error when trying to subscribe a London region Lambda function to an SNS Topic in Ireland.

If anyone knows of a workaround that would be really helpful? Thanks

0reactions
davidnewhallcommented, Nov 3, 2022

Use fromFunctionAttributes instead of fromFunctionArn and set sameEnvironment to false. This will prevent CDK/CFN from trying to add invoke permissions to a lambda in another region (that it cannot reach).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve authorization errors when subscribing Lambda ...
When you subscribe a Lambda function to an SNS topic, you can receive an authorization error for the following reasons:.
Read more >
Error creating lambda to invoke from SNS Topic events in ...
I am trying to create a lambda function which can be invoked from SNS Topic events in the different region. My lambda is...
Read more >
Why do I get an authorization error when subscribing my ...
Why do I get an authorization error when subscribing my Lambda function to my Amazon SNS topic? 539 views 1 month ago. Amazon ......
Read more >
AWS Lambda Events - SNS - Serverless Framework
You're also able to add the same SNS topic to multiple functions: ... Note: The arn can be in a different region to...
Read more >
aws.sns.TopicSubscription - Pulumi
NOTE: If an SNS topic and SQS queue are in different AWS accounts and different AWS regions, the subscription needs to be initiated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found