(apigateway): setting deployOptions metricsEnabled causes throttling properties to be set to default values.
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When creating an API Gateway resource with stage [setting](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.CfnDeployment.MethodSettingProperty.html) (`deployOptions`), `metricsEnabled: true`, throttling is enabled with default values (`throttlingBurstLimit: 5000`, `throttlingRateLimit: 10000.0`) even though those properties are omitted.
Related: https://github.com/aws/aws-cdk/issues/20860
### Expected Behavior
I expect to be able to set `metricsEnabled`, and omit `throttlingBurstLimit` and `throttlingRateLimit` (in deployOptions) and throttling is _not_ enabled on the API gateway stage.
**OR**
I can set the values, `throttlingBurstLimit: -1` and `throttlingRateLimit: -1.0` to explicitly disable throttling (this is how they are reported from AWS CLI when throttling is disabled, but CloudFormation rejects those values).
### Current Behavior
When a new API Gateway is created with `metricsEnabled: true`, the 'prod' stage has throttling enabled with the values, `throttlingBurstLimit: 5000`; `throttlingRateLimit: 10000.0`


### Reproduction Steps
Create a new API Gateway using the code block,
```
const api = new apigateway.RestApi(this, "blarn-api", {
endpointConfiguration: {
types: [ apigateway.EndpointType.REGIONAL ]
},
restApiName: "foo",
deployOptions: {
methodOptions: {
'/*/*': {
loggingLevel: apigateway.MethodLoggingLevel.OFF,
metricsEnabled: true,
}
}
}
})
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.33.0 (build 859272d)
### Framework Version
_No response_
### Node.js Version
v18.6.0
### OS
Ubuntu 20.04.4 LTS
### Language
Typescript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start with the deployOptions.methodOptions entry point and reproduce the issue using the TypeScript example. Inspect the generated API Gateway stage method settings and add a regression test covering metricsEnabled with omitted throttling values. Done means enabling metrics no longer applies the 5000 and 10000 default throttling values, or the documented explicit disabling behavior works.
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
- 48/100