aws / aws/aws-cdk

(apigateway): RestApi not redeploying correctly

Open
#14,660 8 comments 20 reactions 0 assignees View on GitHub
@aws-cdk/aws-apigateway bug effort/large needs-design p1
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

When I change a resource path in a RestApi the old path is not removed from the api stage.
The `deploy` option of RestApi should update the stage when a change occur in the api.

### Reproduction Steps
The initial stack:

const api: RestApi = new RestApi(this, 'rest-api', {
deploy: true,
deployOptions: {
stageName: 'test-stage'
}
})

const myResource:IResource = api.root.addResource("myResource", {})

myResource.addMethod("GET",
new Integration({
type:IntegrationType.MOCK,
integrationHttpMethod:'ANY'
})
)

The deployed resources:
![image](https://user-images.githubusercontent.com/72744989/117972650-ad74a300-b32b-11eb-9a36-e18d9600f26c.png)
The stage:
![image](https://user-images.githubusercontent.com/72744989/117972708-be251900-b32b-11eb-94c4-3e1a3f934e4c.png)

If I change the path of the resource:
`const myResource:IResource = api.root.addResource("myResourceChanged", {})
`
and redeploy the stack

### What did you expect to happen?
The expect deployed resources:
![image](https://user-images.githubusercontent.com/72744989/117973035-283dbe00-b32c-11eb-91a9-b90e41f59a75.png)
The expect stage:
![image](https://user-images.githubusercontent.com/72744989/117973407-a69a6000-b32c-11eb-9532-2a218249b660.png)

### What actually happened?
The new deployed resources:
![image](https://user-images.githubusercontent.com/72744989/117973035-283dbe00-b32c-11eb-91a9-b90e41f59a75.png)
The new stage:
![image](https://user-images.githubusercontent.com/72744989/117973055-325fbc80-b32c-11eb-9500-133fc78909c5.png)

If I manually redeploy the stage from the console, the /myResource is removed from the stage.

### Environment

- **CDK CLI Version :*1.103.0 (build bc13a66)*
- **Framework Version:**
- **Node.js Version:*v14.13.1*
- **OS :*Windows 10*
- **Language (Version):*TypeScript(3.9.7)*

### Other

---

This is :bug: Bug Report

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the TypeScript RestApi example with deploy enabled and a named stage, then inspect the RestApi deployment behavior when the resource path changes. Done means redeploying the stack removes the old path from the API stage without requiring a manual console redeployment.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.