[AWS][WAF][Rate-based rule]rate-based limitを使って気楽にDDoS攻撃を防げる!
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/wafv2_web_acl
- waf.tf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | resource "aws_wafv2_web_acl" "hoge_waf_acl" { description = "Rate-based-rule" name = "Rate-based-rule" scope = "REGIONAL" default_action { allow { } } rule { name = "Rate-based-rule" priority = 0 action { block { } } statement { rate_based_statement { aggregate_key_type = "IP" limit = 1000 } } visibility_config { cloudwatch_metrics_enabled = true metric_name = "Rate-based-rule" sampled_requests_enabled = true } } visibility_config { cloudwatch_metrics_enabled = true metric_name = "Rate-based-rule" sampled_requests_enabled = true } } resource "aws_wafv2_web_acl_association" "hoge_waf_rule" { resource_arn = aws_lb.hoge_app.arn web_acl_arn = aws_wafv2_web_acl.hoge_waf_acl.arn } |
設定項目が多すぎるので、一度手動で設定してimport化したほうが早い。
Was this helpful?
0 / 0
1989年生まれのSRE。ホスティングから大規模なアドテクなどのインフラエンジニアとして携わる。現在はサービスの信頼性向上、DevOps、可用性、レイテンシ、パフォーマンス、モニタリング、オブザーバビリティ、緊急対応、AWS/Azureでのインフラ構築、Docker開発環境の提供、Kubernetes保守、インフラコード化、新技術の検証、リファクタリング、セキュリティ強化などを担当している。個人事業主では数社サーバー保守とベンチャー企業のSREインフラコンサルティングやMENTA/CloudTech Academyで未経験者にインフラのコーチング/コミュニティの運用を実施している。また、「脆弱性スキャナVuls」のOSS活動もしており、自称エバンジェリスト/技術広報/テクニカルサポート/コントリビュータでもある。