aws / aws/aws-cdk

aws_apigateway: RestAPI stage variables not deleted

Open
#23,438 9 comments 3 reactions 1 assignee Claimed by @otaviomacedo View on GitHub
@aws-cdk/aws-apigateway bug needs-cfn p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

RestAPI stage has variable, e.g. 'key1:value1'.
When you change it to 'key2:value2' CDK creates new variable but doesn't delete old variable.

![cdk](https://user-images.githubusercontent.com/19704782/209115581-23152045-304d-447c-8215-1053593aa7b6.png)

### Expected Behavior

CDK replaces old variable with new variable.

### Current Behavior

CDK creates new variable, but doesn't delele old variable.

### Reproduction Steps

- Deploy stack:

`
from aws_cdk import (
Stack,
aws_apigateway as apigateway
)
from constructs import Construct

class TestStack(Stack):

def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

deploy_options = apigateway.StageOptions(
stage_name="prod",
variables={"key1":"value1"}
)

api = apigateway.RestApi(self, 'testApi',
deploy_options=deploy_options
)
api.root.add_method('GET')
`

- Replace {"key1":"value1"} with {"key2":"value2"} in code
- Run cdk diff. Diff is ok, it shows key1 should be deleted.

13:23:38 Resources
13:23:38 [~] AWS::ApiGateway::Stage testApi/DeploymentStage.prod testApiDeploymentStageprodCE051BE8
13:23:38 └─ [~] Variables
13:23:38 ├─ [-] Removed: .key1
13:23:38 └─ [+] Added: .key2

- Deploy, then go to AWS console -> old variable is not deleted

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.55.1

### Framework Version

_No response_

### Node.js Version

18.0.0

### OS

Ubuntu 22.04

### Language

Python

### Language Version

3.10

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.