Shr*_*mpy 0 terraform amazon-waf terraform-provider-aws
我设法使用 Terraform 脚本在 AWS 上构建了一个 WAF(v1) 基础设施组件。自 2019 年 11 月起,AWS 建议改用 WAFv2,但我不知道如何使用 Terraform 编写此脚本。
当然,这里是 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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2318 次 |
| 最近记录: |