Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws_apigateway): empty policy attribute for CfnRestApi fails synthesize #29175

Open
jwoehrle opened this issue Feb 20, 2024 · 3 comments
Open
Labels
bug This issue is a bug. cli Issues related to the CDK CLI effort/medium Medium work item – several days of effort p2

Comments

@jwoehrle
Copy link
Contributor

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 jwoehrle added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 20, 2024
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Feb 20, 2024
@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 20, 2024
@pahud
Copy link
Contributor

pahud commented Feb 20, 2024

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

@TheRealAmazonKendra
Copy link
Contributor

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 TheRealAmazonKendra removed their assignment Feb 21, 2024
@moelasmar moelasmar self-assigned this Aug 30, 2024
@moelasmar
Copy link
Contributor

I believe this is a CFN schema issue. Policy attribute is of type JSON as per CFN docs, but it accepts an empty string as a valid JSON which is not correct, so if string is an accepted type, so I believe this should be reflected in the CFN schema of the "AWS::ApiGateway::RestApi" resource.

Also, I do not think this is a P1 issue as the empty string policy is actually handled the same as null.

@moelasmar moelasmar added p2 cli Issues related to the CDK CLI toolkit/migrate Related to cdk migrate and removed p1 @aws-cdk/aws-apigateway Related to Amazon API Gateway toolkit/migrate Related to cdk migrate labels Sep 8, 2024
@moelasmar moelasmar removed their assignment Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. cli Issues related to the CDK CLI effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

4 participants