AWS::WAFv2::WebACLAssociation - AWS CloudFormation

AWS::WAFv2::WebACLAssociation

Note

This is the latest version of AWS WAF, named AWS WAFV2, released in November, 2019. For information, including how to migrate your AWS WAF resources from the prior release, see the AWS WAF Developer Guide.

Use a web ACL association to define an association between a Web ACL and a regional application resource, to protect the resource. A regional application can be an Application Load Balancer (ALB) or an API Gateway stage.

For AWS CloudFront, don't use this resource. Instead, use your CloudFront distribution configuration. To associate a Web ACL with a distribution, provide the Amazon Resource Name (ARN) of the AWS::WAFv2::WebACL to your CloudFront distribution configuration. To disassociate a web ACL, provide an empty ARN. For information, see AWS::CloudFront::Distribution.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::WAFv2::WebACLAssociation", "Properties" : { "ResourceArn" : String, "WebACLArn" : String } }

YAML

Type: AWS::WAFv2::WebACLAssociation Properties: ResourceArn: String WebACLArn: String

Properties

ResourceArn

The Amazon Resource Name (ARN) of the resource to associate with the web ACL.

The ARN must be in one of the following formats:

  • For an Application Load Balancer: arn:aws:elasticloadbalancing:region:account-id:loadbalancer/app/load-balancer-name/load-balancer-id

  • For an Amazon API Gateway stage: arn:aws:apigateway:region::/restapis/api-id/stages/stage-name

Required: Yes

Type: String

Minimum: 20

Maximum: 2048

Pattern: .*\S.*

Update requires: Replacement

WebACLArn

The Amazon Resource Name (ARN) of the Web ACL that you want to associate with the resource.

Required: Yes

Type: String

Minimum: 20

Maximum: 2048

Pattern: .*\S.*

Update requires: Replacement

Return values

Ref

The Ref for the resource, containing the resource name, physical ID, and scope, formatted as follows: name|id|scope.

For example: my-webacl-name|1234a1a-a1b1-12a1-abcd-a123b123456|REGIONAL

Examples

Create a web ACL association

The following shows an example web ACL association specification.

YAML

Resources: SampleWebACLAssociation: Type: 'AWS::WAFv2::WebACLAssociation' Properties: WebACLArn: ExampleARNForWebACL ResourceArn: ExampleARNForRegionalResource

JSON

"Resources": { "SampleWebACLAssociation": { "Type": "AWS::WAFv2::WebACLAssociation", "Properties": { "WebACLArn": "WebACLArn", "ResourceArn": "APIGatewayOrALBArn" } } }