aws / aws/aws-cdk

aws-apigateway: Canary Deployment Settings Not Removed from Stage

Open
#33,901 4 comments 2 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

When using an `aws_apigateway.SpecRestApi` with `deploy: true` and deploy options configured, I set a canary deployment on the stage via:

```
const canaryStage = apiGateway.deploymentStage.node.defaultChild as aws_apigateway.CfnStage;
canaryStage.canarySetting = {
deploymentId: apiGateway.latestDeployment?.deploymentId,
percentTraffic: canaryPercentTraffic,
stageVariableOverrides: canaryVariables
};
```

After deployment the Canary Configuration works as expected.
However, if I remove this configuration from the code, the canary settings are removed from the CloudFormation stack (as seen in cdk diff) but still persist in the API Gateway stage after cdk deploy.

cdk diff output
```
[~] AWS::ApiGateway::Stage Gateway/ApiGateway/DeploymentStage.preview GatewayApiGatewayDeploymentStagepreviewFCB0F3EC
├─ [-] CanarySetting
│ └─ {"DeploymentId":{"Ref":"..."},"PercentTraffic":50,"StageVariableOverrides":{"stage":"test"}}
...
```

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Version

_No response_

### Expected Behavior

Removing the canary configuration from the CDK code should also remove the canary deployment settings from the API Gateway stage.

### Current Behavior

The canary settings persist on the deployed API Gateway stage despite being removed from the stack configuration.

### Reproduction Steps

* Create an aws_apigateway.SpecRestApi with deploy: true and set deploy options.
* Apply a canary configuration to the stage using the code snippet above.
* Deploy the stack.
* Remove the canary configuration from the CDK code.
* Run cdk diff (shows removal) and then cdk deploy.
* Observe that the API Gateway stage still retains the canary settings.

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.1004.0

### Framework Version

_No response_

### Node.js Version

v20.17.0

### OS

mac-os

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with aws_apigateway.SpecRestApi deployment handling and the deploymentStage.node.defaultChild CfnStage entry point, focusing on how canarySetting removals are rendered and applied. Reproduce the sequence with cdk diff and cdk deploy, then verify that removing the configuration also removes the canary settings from the API Gateway stage.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
api, cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.