Skip to content

Commit 5b0dbb6

Browse files
committed
updated security file
1 parent 88743d9 commit 5b0dbb6

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

rds.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@ resource "aws_db_instance" "database-instance" {
4343
db_name = "webappdb"
4444
# amazonq-ignore-next-line
4545
skip_final_snapshot = true
46+
47+
# Enable log exports to CloudWatch
48+
enabled_cloudwatch_logs_exports = [
49+
"audit",
50+
"error",
51+
"general",
52+
"slowquery"
53+
]
4654
}

security.tf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,13 @@ resource "aws_wafv2_web_acl" "web_acl" {
125125
# This rule is a pre-configured rule set from AWS
126126
# that protects against common exploits like SQLi and XSS.
127127
rule {
128-
name = "AWS-AWSManagedRulesCommonRuleSet"
128+
# Use a unique name for this rule
129+
name = "CommonRuleSet"
129130
priority = 1
130131
statement {
131132
managed_rule_group_statement {
132133
vendor_name = "AWS"
134+
# This is the correct managed rule group name from AWS
133135
name = "AWSManagedRulesCommonRuleSet"
134136
}
135137
}
@@ -139,18 +141,20 @@ resource "aws_wafv2_web_acl" "web_acl" {
139141
}
140142
visibility_config {
141143
cloudwatch_metrics_enabled = true
142-
metric_name = "CommonRuleSet"
144+
metric_name = "CommonRuleSetMetrics" # Must be unique
143145
sampled_requests_enabled = true
144146
}
145147
}
146148

147-
# Rule to protect against Log4j2 vulnerabilities
149+
# Rule to protect against Log4j2 vulnerabilities and other bad inputs
148150
rule {
149-
name = "AWS-AWSManagedRulesKnownBadInputsRuleSet"
151+
# Use a unique name for this rule
152+
name = "KnownBadInputs"
150153
priority = 2
151154
statement {
152155
managed_rule_group_statement {
153156
vendor_name = "AWS"
157+
# This is the correct managed rule group name from AWS
154158
name = "AWSManagedRulesKnownBadInputsRuleSet"
155159
}
156160
}
@@ -159,7 +163,7 @@ resource "aws_wafv2_web_acl" "web_acl" {
159163
}
160164
visibility_config {
161165
cloudwatch_metrics_enabled = true
162-
metric_name = "KnownBadInputsRuleSet"
166+
metric_name = "KnownBadInputsMetrics" # Must be unique
163167
sampled_requests_enabled = true
164168
}
165169
}
@@ -175,4 +179,4 @@ resource "aws_wafv2_web_acl" "web_acl" {
175179
resource "aws_wafv2_web_acl_association" "web_acl_assoc" {
176180
resource_arn = aws_lb.web_alb.arn
177181
web_acl_arn = aws_wafv2_web_acl.web_acl.arn
178-
}
182+
}

0 commit comments

Comments
 (0)