/* Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ resource "aws_wafv2_web_acl" "cdn_packages_k8s_io" { # WAF Web ACLs for CloudFront distribution must be created in us-east-1 (required by AWS) provider = aws.us-east-1 name = "${local.prefix}PackagesCloudFrontWebACL" description = "WAF Web ACL used by cdn.packages.k8s.io CloudFront." scope = "CLOUDFRONT" default_action { allow {} } rule { name = "AWS-AWSManagedRulesAmazonIpReputationList" priority = 0 statement { managed_rule_group_statement { name = "AWSManagedRulesAmazonIpReputationList" vendor_name = "AWS" } } override_action { none {} } visibility_config { cloudwatch_metrics_enabled = true sampled_requests_enabled = true metric_name = "AWS-AWSManagedRulesAmazonIpReputationList" } } rule { name = "AWS-AWSManagedRulesCommonRuleSet" priority = 1 statement { managed_rule_group_statement { name = "AWSManagedRulesCommonRuleSet" vendor_name = "AWS" // Older yum versions (e.g. 3.4.3 used on CentOS 7) are triggering // this rule which makes yum fail with 403 Forbidden. rule_action_override { name = "UserAgent_BadBots_HEADER" action_to_use { count {} } } // tdnf used on Photon OS doesn't send a user agent header so // this rule is being triggered which makes tdnf fail with 403 Forbidden. rule_action_override { name = "NoUserAgent_HEADER" action_to_use { count {} } } } } override_action { none {} } visibility_config { cloudwatch_metrics_enabled = true sampled_requests_enabled = true metric_name = "AWS-AWSManagedRulesCommonRuleSet" } } rule { name = "AWS-AWSManagedRulesKnownBadInputsRuleSet" priority = 2 statement { managed_rule_group_statement { name = "AWSManagedRulesKnownBadInputsRuleSet" vendor_name = "AWS" } } override_action { none {} } visibility_config { cloudwatch_metrics_enabled = true sampled_requests_enabled = true metric_name = "AWS-AWSManagedRulesKnownBadInputsRuleSet" } } visibility_config { cloudwatch_metrics_enabled = true sampled_requests_enabled = true metric_name = "${local.prefix}PackagesCloudFrontWebACL" } tags = local.tags }