aws_apigateway: RestAPI stage variables not deleted
- 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.

### 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
Assessment
This issue has not been assessed yet.