Remediation
Associate an AWS WAF Web ACL with the CloudFront Distributionβ
To protect Amazon CloudFront distributions with AWS WAF, create and configure a web ACL and associate it with the target distribution.
From Command Lineβ
-
Create or identify an AWS WAF Web ACL
Ensure an appropriate web ACL exists with the required rule sets. This may include AWS Managed Rules, marketplace rule groups, or custom rules aligned with your organizationβs security policies.
-
Retrieve the current CloudFront distribution configuration and ETag
Download the existing distribution configuration and capture the associated
ETag, which is required to apply updates:aws cloudfront get-distribution-config \
--id {{distribution-id}} \
--query 'DistributionConfig' \
> {{distribution-config}}.json
ETAG=$(aws cloudfront get-distribution-config \
--id {{distribution-id}} \
--query 'ETag' \
--output text) -
Update the Web ACL association
Edit the downloaded
{{distribution-config}}.jsonfile and set theWebACLIdattribute:-
For AWS WAF (v2), specify the web ACL ARN, for example:
arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 -
For AWS WAF Classic, specify the web ACL ID, for example:
a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
-
-
Apply the updated CloudFront distribution configuration
Use the previously captured
ETagto update the distribution:aws cloudfront update-distribution \
--id {{distribution-id}} \
--if-match $ETAG \
--distribution-config file://{{distribution-config}}.json