[sns] Lambda function in different region subscription error
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
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: Bug Report
Contributor guide
Research direction
Start by tracing lambda.Function.fromFunctionArn and topic.addSubscription(new subscription.LambdaSubscription(...)) in the CDK source, focusing on how the imported Lambda region is handled. Reproduce the ap-southeast-2 Lambda and us-east-1 SNS topic case, then verify that creating the subscription no longer raises the cross-region ResourceNotFoundException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100