Aws-cdk: wafv2: CfnWebACLAssociation missing

Created on 17 Feb 2020  路  2Comments  路  Source: aws/aws-cdk

CfnWebACLAssociation is missing from wafv2 package.

Probably related to spec update mentioned in #6056

Reproduction Steps

Psuedo code below but gets the idea across.

import wafv2 = require('@aws-cdk/aws-wafv2');

const webAcl = new wafv2.CfnWebAcl(this, 'WebAcl');

new wafv2.CfnWebACLAssociation(this, 'ALBAssociation', {
  resourceArn: lb.loadBalancerArn,
  webACLArn: webAcl.attrArn
});

Error Log

N/A, resource doesn't exist in package

Environment

  • CLI Version : 1.19.0
  • Framework Version: 1.19.0
  • OS : macOS
  • Language : TypeScript

Other

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-webaclassociation.html


This is :bug: Bug Report

@aws-cdaws-wafv2 bug needs-cfn p2

Most helpful comment

I made a quick and dirty CfnResource for now.

import { CfnResource, Construct, requireProperty, Token, TreeInspector } from '@aws-cdk/core';

export interface CfnWebACLAssociationProps {
  resourceArn: string;
  webACLArn: string;
}

export class CfnWebACLAssociation extends CfnResource {
  private static readonly CFN_RESOURCE_TYPE_NAME = 'AWS::WAFv2::WebACLAssociation';
  private readonly resourceArn: string;
  private readonly webACLArn: string;

  constructor(scope: Construct, id: string, props: CfnWebACLAssociationProps) {
    super(scope, id, { type: CfnWebACLAssociation.CFN_RESOURCE_TYPE_NAME, properties: props });

    requireProperty(props, 'resourceArn', this);
    requireProperty(props, 'webACLArn', this);

    this.resourceArn = props.resourceArn;
    this.webACLArn = props.webACLArn;
  }

  inspect(inspector: TreeInspector) {
    inspector.addAttribute(
      'aws:cdk:cloudformation:type',
      CfnWebACLAssociation.CFN_RESOURCE_TYPE_NAME
    );
    inspector.addAttribute('aws:cdk:cloudformation:props', this.cfnProperties);
  }

  get cfnProperties() {
    return {
      resourceArn: this.resourceArn,
      webACLArn: this.webACLArn,
    };
  }
  renderProperties() {
    // TODO: validations
    return {
      ResourceArn: Token.asString(this.resourceArn),
      WebACLArn: Token.asString(this.webACLArn),
    };
  }
}

All 2 comments

I made a quick and dirty CfnResource for now.

import { CfnResource, Construct, requireProperty, Token, TreeInspector } from '@aws-cdk/core';

export interface CfnWebACLAssociationProps {
  resourceArn: string;
  webACLArn: string;
}

export class CfnWebACLAssociation extends CfnResource {
  private static readonly CFN_RESOURCE_TYPE_NAME = 'AWS::WAFv2::WebACLAssociation';
  private readonly resourceArn: string;
  private readonly webACLArn: string;

  constructor(scope: Construct, id: string, props: CfnWebACLAssociationProps) {
    super(scope, id, { type: CfnWebACLAssociation.CFN_RESOURCE_TYPE_NAME, properties: props });

    requireProperty(props, 'resourceArn', this);
    requireProperty(props, 'webACLArn', this);

    this.resourceArn = props.resourceArn;
    this.webACLArn = props.webACLArn;
  }

  inspect(inspector: TreeInspector) {
    inspector.addAttribute(
      'aws:cdk:cloudformation:type',
      CfnWebACLAssociation.CFN_RESOURCE_TYPE_NAME
    );
    inspector.addAttribute('aws:cdk:cloudformation:props', this.cfnProperties);
  }

  get cfnProperties() {
    return {
      resourceArn: this.resourceArn,
      webACLArn: this.webACLArn,
    };
  }
  renderProperties() {
    // TODO: validations
    return {
      ResourceArn: Token.asString(this.resourceArn),
      WebACLArn: Token.asString(this.webACLArn),
    };
  }
}

Now available in CloudFormation spec

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PaulMaddox picture PaulMaddox  路  3Comments

abelmokadem picture abelmokadem  路  3Comments

eladb picture eladb  路  3Comments

ababra picture ababra  路  3Comments

EduardTheThird picture EduardTheThird  路  3Comments