CloudFront is not associated with AWS WAF

Apply AWS WAF rules suited to the service through CloudFront.

Description

Associate a web ACL with the CloudFront distribution to apply AWS WAF rules to its incoming requests.

Potential impact

Without the filters or rate limits the service needs, unwanted traffic can place extra load on the origin.

Remediation

Set DistributionConfig.WebACLId to the ARN of a WAFv2 web ACL created in us-east-1 with CLOUDFRONT scope. Choose managed or rate-based rules for your service and verify that legitimate traffic still passes.

Examples

The second excerpt references CloudFrontWebAclArn. Supply the web ACL, its rules and the rest of the distribution configuration, including myOrigin.

Before

yaml
Resources:
  WebDistribution:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
        Enabled: true
        DefaultCacheBehavior:
          TargetOriginId: myOrigin

After

yaml
Resources:
  WebDistribution:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
        Enabled: true
        DefaultCacheBehavior:
          TargetOriginId: myOrigin
        WebACLId: !Ref CloudFrontWebAclArn

References