Skip to content

aws-apigateway: Canary Deployment Settings Not Removed from Stage #33901

Open
@FelixWe

Description

@FelixWe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-apigatewayRelated to Amazon API GatewaybugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions