CfnWebACLAssociation is missing from wafv2 package.
Probably related to spec update mentioned in #6056
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
});
N/A, resource doesn't exist in package
This is :bug: Bug Report
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
Most helpful comment
I made a quick and dirty
CfnResourcefor now.