Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/automation/var/project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ TF_VAR_waf_ip_allow_list_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-ip
TF_VAR_waf_rate_based_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-rate-based-rule
TF_VAR_waf_aws_known_bad_inputs_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-aws-known-bad-inputs-rule
TF_VAR_waf_aws_sqli_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-aws-sqli-rule
TF_VAR_waf_custom_sqli_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-custom-sqli-rule

# -------------------------------
# BLUE/GREEN ENVIRONMENT VARIABLES
Expand Down
20 changes: 20 additions & 0 deletions infrastructure/stacks/shared-resources/cloudwatch-waf-alarms.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@ resource "aws_cloudwatch_metric_alarm" "waf_aws_managed_sql_injection_blocked_re
threshold = "1"
}

resource "aws_cloudwatch_metric_alarm" "waf_custom_sql_injection_count_requests" {
count = var.waf_enabled ? 1 : 0
alarm_actions = [aws_sns_topic.shared_resources_sns_topic_app_alerts_for_slack_default_region.arn]
alarm_description = "WAF Custom SQL Injection Count Requests"
alarm_name = "${var.project_id} | ${var.shared_environment} | WAF Custom SQL Injection Count Requests"
comparison_operator = "GreaterThanThreshold"
datapoints_to_alarm = "1"
dimensions = {
Rule = var.waf_custom_sqli_rule_name
WebACL = var.waf_acl_name,
Region = var.aws_region
}
evaluation_periods = "1"
metric_name = "CountedRequests"
namespace = "AWS/WAFV2"
period = "60"
statistic = "Sum"
threshold = "1"
}

resource "aws_cloudwatch_metric_alarm" "waf_aws_managed_ip_reputation_list_blocked_requests" {
count = var.waf_enabled ? 1 : 0
alarm_actions = [aws_sns_topic.shared_resources_sns_topic_app_alerts_for_slack_default_region.arn]
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/stacks/shared-resources/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,8 @@ variable "waf_aws_sqli_rule_name" {
type = string
description = "WAF AWS SQLi rule name"
}

variable "waf_custom_sqli_rule_name" {
type = string
description = "WAF custom SQLi rule name"
}
27 changes: 27 additions & 0 deletions infrastructure/stacks/shared-resources/waf.tf
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,33 @@ resource "aws_wafv2_web_acl" "di_endpoint_waf" {
}
}

rule {
name = var.waf_custom_sqli_rule_name
priority = 8

action {
count {}
}

statement {
sqli_match_statement {
field_to_match {
body {}
}
sensitivity_level = "HIGH"
text_transformation {
priority = 0
type = "NONE"
}
}
}
visibility_config {
sampled_requests_enabled = true
metric_name = var.waf_custom_sqli_rule_name
cloudwatch_metrics_enabled = true
}
}

rule {
name = var.waf_ip_reputation_list_rule_name
priority = 7
Expand Down
Loading