-
Notifications
You must be signed in to change notification settings - Fork 2
Add WAF protection to application load balancers #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ffd311d
Add WAF protection to application load balancers
devin-ai-integration[bot] 7a96e57
Add WAF logging configuration and Log4j2 protection
devin-ai-integration[bot] 8ad8e5c
Add KMS encryption to WAF CloudWatch logs
devin-ai-integration[bot] b920383
Fix reference to network module in service root module
devin-ai-integration[bot] cf4faff
Remove KMS key and add checkov skip comment for CKV_AWS_158
devin-ai-integration[bot] fe3b98b
Fix checkov skip comment placement for CKV_AWS_158
devin-ai-integration[bot] ba4c5ce
Move checkov skip comment inside resource block
devin-ai-integration[bot] 3be8581
Fix network module reference in service root module
devin-ai-integration[bot] 3fb68f5
Add network module import to service root module
devin-ai-integration[bot] 1417345
Address PR feedback: replace waf_arn with enable_waf and reorganize code
devin-ai-integration[bot] 338f06d
Add enable_waf variable to network data module
devin-ai-integration[bot] f01d62d
Update WAF data source to use enable_waf variable
devin-ai-integration[bot] 0e20691
Add enable_waf variable to network resources module
devin-ai-integration[bot] 831407d
Make WAF resources conditional based on enable_waf variable
devin-ai-integration[bot] c8ef7be
Revert conditional WAF creation and remove enable_waf variables from …
devin-ai-integration[bot] fe65d9a
Tweaks
lorenyu 90afea0
Remove unused variable
lorenyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| resource "aws_wafv2_web_acl" "main" { | ||
| name = module.interface.waf_acl_name | ||
| description = "WAF to protect application load balancers in the ${var.name} network" | ||
| scope = "REGIONAL" | ||
|
|
||
| default_action { | ||
| allow {} | ||
| } | ||
|
|
||
| rule { | ||
| name = "AWS-AWSManagedRulesCommonRuleSet" | ||
| priority = 1 | ||
|
|
||
| override_action { | ||
| none {} | ||
| } | ||
|
|
||
| statement { | ||
| managed_rule_group_statement { | ||
| name = "AWSManagedRulesCommonRuleSet" | ||
| vendor_name = "AWS" | ||
| } | ||
| } | ||
|
|
||
| visibility_config { | ||
| cloudwatch_metrics_enabled = true | ||
| metric_name = "AWS-AWSManagedRulesCommonRuleSet" | ||
| sampled_requests_enabled = true | ||
| } | ||
| } | ||
|
|
||
| rule { | ||
| name = "AWS-AWSManagedRulesKnownBadInputsRuleSet" | ||
| priority = 2 | ||
|
|
||
| override_action { | ||
| none {} | ||
| } | ||
|
|
||
| statement { | ||
| managed_rule_group_statement { | ||
| name = "AWSManagedRulesKnownBadInputsRuleSet" | ||
| vendor_name = "AWS" | ||
| } | ||
| } | ||
|
|
||
| visibility_config { | ||
| cloudwatch_metrics_enabled = true | ||
| metric_name = "AWS-AWSManagedRulesKnownBadInputsRuleSet" | ||
| sampled_requests_enabled = true | ||
| } | ||
| } | ||
|
|
||
| visibility_config { | ||
| cloudwatch_metrics_enabled = true | ||
| metric_name = "${var.name}-waf" | ||
| sampled_requests_enabled = true | ||
| } | ||
|
|
||
| tags = { | ||
| Name = var.name | ||
| } | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_log_group" "waf_logs" { | ||
| name = "aws-waf-logs-${var.name}" | ||
| retention_in_days = 30 | ||
| kms_key_id = aws_kms_key.waf_logs.arn | ||
| } | ||
|
|
||
| resource "aws_kms_key" "waf_logs" { | ||
| description = "KMS key for WAF logs encryption" | ||
| deletion_window_in_days = 7 | ||
| enable_key_rotation = true | ||
| } | ||
|
|
||
| resource "aws_kms_alias" "waf_logs" { | ||
| name = "alias/${var.name}-waf-logs" | ||
| target_key_id = aws_kms_key.waf_logs.key_id | ||
| } | ||
|
|
||
| resource "aws_wafv2_web_acl_logging_configuration" "main" { | ||
| log_destination_configs = [aws_cloudwatch_log_group.waf_logs.arn] | ||
| resource_arn = aws_wafv2_web_acl.main.arn | ||
| } | ||
|
|
||
| output "waf_arn" { | ||
| value = aws_wafv2_web_acl.main.arn | ||
| } | ||
|
lorenyu marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| resource "aws_wafv2_web_acl_association" "main" { | ||
| count = var.waf_arn != null ? 1 : 0 | ||
| resource_arn = aws_lb.alb.arn | ||
| web_acl_arn = var.waf_arn | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.