(aws_apigateway): empty policy attribute for CfnRestApi fails synthesize
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the bug
I'm playing with `cdk migrate` and came across an IMO general CDK issue.
The following CloudFormation Resource deploys just fine:
```
"ApiGatewayRestApi": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Name": "serverless-project-dev",
"EndpointConfiguration": {
"Types": [
"EDGE"
]
},
"Policy": "",
"MinimumCompressionSize": 1024
}
},
```
Note the empty string for the `Policy` attribute
Migrated into CDK with `cdk migrate` this results in the following L1 construct:
```
const apiGatewayRestApi = new apigateway.CfnRestApi(this, 'ApiGatewayRestApi', {
name: 'serverless-project-dev',
endpointConfiguration: {
types: [
'EDGE',
],
},
policy: '',
minimumCompressionSize: 1024,
});
```
which fails synthesis with the following error:
> CfnSynthesisError: Resolution error: Supplied properties not correct for "CfnRestApiProps"
policy: "" should be an 'object'.
When I remove the `policy` key completely synthesis succeeds
### Expected Behavior
L1 constructs should behave like CFN and therefore an empty string as policy value should succeed
### Current Behavior
cdk synth fails
### Reproduction Steps
try to deploy a CfnRestApi with empty string as value for `policy` attribute
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.128.0 (build d995261)
### Framework Version
_No response_
### Node.js Version
v20.9.0
### OS
macOS
### Language
TypeScript
### Language Version
TypeScript (~5.3.3)
### Other information
_No response_
Contributor guide
Research direction
The issue identifies the TypeScript CfnRestApi reproduction and its policy attribute; start by running the reported cdk synth case and tracing validation of CfnRestApi.policy. Done means an empty-string policy synthesizes successfully while omitting policy continues to work, with the behavior covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, devtools, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100