aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

(aws_apigateway): empty policy attribute for CfnRestApi fails synthesize

Open jwoehrle opened this issue 1 year ago • 2 comments

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

jwoehrle avatar Feb 20 '24 10:02 jwoehrle

Thank you for the report. We'll bring this up to the maintainer for further investigation.

pahud avatar Feb 20 '24 18:02 pahud

As this is a problem across our L1s and is not specific to CDK migrate, I'm un-assigning myself on this. I am curious, however, if we accept an empty string for L2s here.

TheRealAmazonKendra avatar Feb 21 '24 21:02 TheRealAmazonKendra