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

ACL Rules property output (and typescript linting) incorrect #6077

Closed
RachelleJanssen opened this issue Feb 3, 2020 · 1 comment
Closed
Assignees
Labels
@aws-cdk/aws-waf Related to AWS Web Application Firewall bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@RachelleJanssen
Copy link

RachelleJanssen commented Feb 3, 2020

When creating a CfnWebACL from @aws-cdk/aws-wafv2 the output is incorrect and results in an Internal Failure when trying to run cdk deploy

Reproduction Steps

The typedef of CfnWebACL has a "rules" property, which is an object containing another "rules" property, which is an array of actual rules.

import * as cdk from "@aws-cdk/core";
import waf = require("@aws-cdk/aws-waf");
import wafv2 = require("@aws-cdk/aws-wafv2");

export class AwsCdkAclStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const acl = new wafv2.CfnWebACL(this, "ACL2", {
      defaultAction: {
        allow: true,
      },
      scope: "CLOUDFRONT",
      visibilityConfig: {
        cloudWatchMetricsEnabled: true,
        metricName: "waf",
        sampledRequestsEnabled: false,
      },
      rules: {
        rules: [
          // rules go here
        ],
      },
    });
  }
}

When running cdk , it outputs a similar wrapper which causes an internal failure on cloudformation

{
  "Resources": {
    "ACL2": {
      "Type": "AWS::WAFv2::WebACL",
      "Properties": {
        "DefaultAction": {
          "Allow": {}
        },
        "Scope": "CLOUDFRONT",
        "VisibilityConfig": {
          "CloudWatchMetricsEnabled": true,
          "MetricName": "waf",
          "SampledRequestsEnabled": false
        },
        "Rules": {
          "Rules": [
            // rule objects go here
          ]
        }
      },
      "Metadata": {
        "aws:cdk:path": "AwsCdkAclStack/ACL2"
      }
    }
  }
}

Error Log

AwsCdkAclStack (ACLTestStack): deploying...
ACLTestStack: creating CloudFormation changeset...
 0/3 | 7:17:31 PM | CREATE_IN_PROGRESS   | AWS::CloudFormation::Stack | ACLTestStack User Initiated
 0/3 | 7:17:35 PM | CREATE_IN_PROGRESS   | AWS::CDK::Metadata | CDKMetadata 
 0/3 | 7:17:35 PM | CREATE_IN_PROGRESS   | AWS::WAFv2::WebACL | AwsCdkAclStack/ACL2 (ACL2)
 1/3 | 7:17:36 PM | CREATE_FAILED        | AWS::WAFv2::WebACL | AwsCdkAclStack/ACL2 (ACL2) Internal Failure
 2/3 | 7:17:37 PM | CREATE_FAILED        | AWS::CDK::Metadata | CDKMetadata Resource creation cancelled
 2/3 | 7:17:37 PM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | ACLTestStack The following resource(s) failed to create: [ACL2, CDKMetadata]. . Rollback requested by user.
 3/3 | 7:17:59 PM | DELETE_COMPLETE      | AWS::WAFv2::WebACL | AwsCdkAclStack/ACL2 (ACL2)
 3/3 | 7:17:59 PM | DELETE_IN_PROGRESS   | AWS::CDK::Metadata | CDKMetadata
 4/3 | 7:18:00 PM | DELETE_COMPLETE      | AWS::CDK::Metadata | CDKMetadata
 5/3 | 7:18:01 PM | ROLLBACK_COMPLETE    | AWS::CloudFormation::Stack | ACLTestStack

Environment

  • CLI Version : 1.17.9
  • Framework Version: 1.22.0 (build 309ac1b)
  • OS : Windows 10 pro Version 10.0.18362 Build 18362
  • Language : Typescript

Other

By manually removing the object wrapper from the cdk.output file
from

"Rules": {
  "Rules": []
}

to

"Rules": []

I'm able to use the cdk.output file in the cloudformation console to create the stack.


This is 🐛 Bug Report

@RachelleJanssen RachelleJanssen added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 3, 2020
@SomayaB SomayaB added the @aws-cdk/aws-waf Related to AWS Web Application Firewall label Feb 4, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Feb 4, 2020

Duplicate of #6056 and the other one has more useful discussion.

@rix0rrr rix0rrr closed this as completed Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-waf Related to AWS Web Application Firewall bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants