aws / aws/aws-cdk

(aws-apigateway): CDK will allow x-region lambda integration that APIG always fails for

Open
#17,458 7 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-apigateway effort/small feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### What is the problem?

In CDK Someone can model an application where an API Gateway lambda integration points to a lambda in a region different than the api gateway endpoint. APIG will even instantiate these, requests won't succeed though.

APIG will fail w/
Execution failed due to configuration error: Functions from 'us-west-2' are not reachable in this region ('us-east-1')

CDK should prevent users from shooting themselves in the foot wherever possible, build time error are easier to catch than runtime error.

### Reproduction Steps

```ts
let integration = new LambdaIntegration(lambda.Function.fromFunctionArn(this, "TenantFunction", `someARNFromADifferentRegion`));

const api = new RestApi(this, `TenantAPI`, {
defaultIntegration: integration
});
```

### What did you expect to happen?

CDK build to fail

### What actually happened?

CDK Build Succeeds, CloudFormation synth succeeds

### CDK CLI Version

1.131.0 (build 7560c79)

### Framework Version

_No response_

### Node.js Version

v12.22.5

### OS

OSx

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the LambdaIntegration path used with RestApi and the Function.fromFunctionArn example, tracing how the referenced function region is handled during CDK build or CloudFormation synth. Reproduce the cross-region case from the issue and make the build fail for an API Gateway integration whose Lambda is in another region; verify that same-region integrations still synthesize successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
api, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.