aws / aws/aws-cdk

AWS APIgateway: fromRestApiAttributes does not bring all the RestAPI configuration

Open
#29,079 23 comments 3 reactions 0 assignees View on GitHub
@aws-cdk/aws-apigateway bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I was following this documentation [section](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway-readme.html#breaking-up-methods-and-resources-across-stacks), where there's a workaround for multiple stack describing api gateway resources:

Breaking up Methods and Resources across Stacks
It is fairly common for REST APIs with a large number of Resources and Methods to hit the [CloudFormation limit](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html) of 500 resources per stack.

So I broke my stack in several nested stacks and imported back my api in each nested stack using the ``fromRestApiAttributes``` method. The correct object was found but not all the configuration appeared.

### Expected Behavior

I was expecting the full object as set during the API creation in the main stack.

### Current Behavior

Dumping the object, I had the following:

```
{
...
defaultIntegration: undefined,
defaultMethodOptions: undefined,
defaultCorsPreflightOptions: undefined
...
}
```

instead of:
```
{
...
defaultIntegration: undefined,
defaultMethodOptions: undefined,
defaultCorsPreflightOptions: { allowOrigins: [Array], allowMethods: [Array] },
...
}
```

### Reproduction Steps

The following piece of code as mentionned in the documentation:
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway-readme.html#breaking-up-methods-and-resources-across-stacks

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.127.0 (build 6c90efc)

### Framework Version

_No response_

### Node.js Version

v21.1.0

### OS

Mac

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Read the linked “Breaking up Methods and Resources across Stacks” documentation and start from the fromRestApiAttributes entry point. Reproduce the import with the documented TypeScript example, then verify that the imported RestApi retains the configured defaultCorsPreflightOptions rather than showing it as undefined.

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.