【问题标题】:Is there a way to create a WAFv2 from a Terraform script有没有办法从 Terraform 脚本创建 WAFv2
【发布时间】:2020-08-20 14:11:41
【问题描述】:

我设法使用 Terraform 脚本在 AWS 上构建了 WAF(v1) 基础设施组件。自 2019 年 11 月起,AWS 建议改用 WAFv2,但我不知道如何使用 Terraform 编写此脚本。

【问题讨论】:

    标签: terraform terraform-provider-aws amazon-waf


    【解决方案1】:

    当然,这是 WAFv2 资源的示例,其中包含速率限制示例规则以及与 ALB 的关联:

    
    resource "aws_wafv2_web_acl" "my_web_acl" {
      name  = "my-web-acl"
      scope = "REGIONAL"
    
      default_action {
        allow {}
      }
    
      rule {
        name     = "RateLimit"
        priority = 1
    
        action {
          block {}
        }
    
        statement {
    
          rate_based_statement {
            aggregate_key_type = "IP"
            limit              = 500
          }
        }
    
        visibility_config {
          cloudwatch_metrics_enabled = true
          metric_name                = "RateLimit"
          sampled_requests_enabled   = true
        }
      }
    
      visibility_config {
        cloudwatch_metrics_enabled = false
        metric_name                = "my-web-acl"
        sampled_requests_enabled   = false
      }
    }
    
    resource "aws_wafv2_web_acl_association" "web_acl_association_my_lb" {
      resource_arn = aws_lb.my_lb.arn
      web_acl_arn  = aws_wafv2_web_acl.my_web_acl.arn
    }
    
    

    【讨论】:

      【解决方案2】:

      terraform 尚不支持此功能。但是,如果您真的想使用 terraform,我已经构建了一个使用 cloudformation 资源部署 wafv2 的模块。你可以找到它->https://github.com/umotif-public/terraform-aws-waf-webaclv2

      它已发布到 terraform 注册表,因此您可以从那里获取它。

      【讨论】:

        猜你喜欢
        • 2012-12-31
        • 2011-03-25
        • 2020-09-22
        • 2022-01-26
        • 1970-01-01
        • 1970-01-01
        • 2017-05-11
        • 2021-12-07
        • 2019-03-26
        相关资源
        最近更新 更多