Skip to content

Commit 1ad50a9

Browse files
committed
eli-285 and 349 adding kms for sns, checkov skip for disabled alarms
1 parent 28a2958 commit 1ad50a9

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

infrastructure/stacks/api-layer/cloudwatch_alarms.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,30 @@ locals {
299299
resource "aws_sns_topic" "cloudwatch_alarms" {
300300
name = "cloudwatch-security-alarms"
301301

302+
kms_master_key_id = aws_kms_key.sns_encryption_key.id
303+
302304
tags = {
303305
Environment = var.environment
304306
Purpose = "security-alerting"
305307
ManagedBy = "terraform"
306308
}
307309
}
308310

311+
resource "aws_kms_key" "sns_encryption_key" {
312+
description = "KMS key for encrypting CloudWatch alarms SNS topic"
313+
deletion_window_in_days = 7
314+
315+
tags = {
316+
Name = "cloudwatch-alarms-sns-encryption-key"
317+
Environment = var.environment
318+
Purpose = "sns-encryption"
319+
ManagedBy = "terraform"
320+
}
321+
}
322+
309323
# Security Alarms (CloudTrail-based)
310324
resource "aws_cloudwatch_metric_alarm" "cloudtrail_custom_metric_alarms" {
325+
# checkov:skip=CKV_AWS_319: Disabling some alarms until service is live
311326
for_each = local.cloudwatch_alarm_config
312327

313328
alarm_name = "SecurityAlert-${each.key}"
@@ -337,6 +352,7 @@ resource "aws_cloudwatch_metric_alarm" "cloudtrail_custom_metric_alarms" {
337352

338353
# API Gateway CloudWatch Alarms
339354
resource "aws_cloudwatch_metric_alarm" "api_gateway_alarms" {
355+
# checkov:skip=CKV_AWS_319: Disabling some alarms until service is live
340356
for_each = local.api_gateway_alarm_config
341357

342358
alarm_name = "APIGateway-${each.key}"

infrastructure/stacks/api-layer/iam_policies.tf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,52 @@ resource "aws_iam_role_policy" "lambda_xray_tracing_policy" {
358358
role = aws_iam_role.eligibility_lambda_role.id
359359
policy = data.aws_iam_policy_document.lambda_xray_tracing_permissions_policy.json
360360
}
361+
362+
# KMS Key Policy for SNS encryption
363+
resource "aws_kms_key_policy" "sns_encryption_key_policy" {
364+
key_id = aws_kms_key.sns_encryption_key.id
365+
policy = jsonencode({
366+
Version = "2012-10-17"
367+
Statement = [
368+
{
369+
Sid = "EnableIAMRootPermissions"
370+
Effect = "Allow"
371+
Principal = {
372+
AWS = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"
373+
}
374+
Action = "kms:*"
375+
Resource = "*"
376+
},
377+
{
378+
Sid = "AllowCloudWatchAlarmsAccess"
379+
Effect = "Allow"
380+
Principal = {
381+
Service = "cloudwatch.amazonaws.com"
382+
}
383+
Action = [
384+
"kms:Encrypt",
385+
"kms:Decrypt",
386+
"kms:ReEncrypt*",
387+
"kms:GenerateDataKey*",
388+
"kms:DescribeKey"
389+
]
390+
Resource = "*"
391+
},
392+
{
393+
Sid = "AllowSNSServiceAccess"
394+
Effect = "Allow"
395+
Principal = {
396+
Service = "sns.amazonaws.com"
397+
}
398+
Action = [
399+
"kms:Encrypt",
400+
"kms:Decrypt",
401+
"kms:ReEncrypt*",
402+
"kms:GenerateDataKey*",
403+
"kms:DescribeKey"
404+
]
405+
Resource = "*"
406+
}
407+
]
408+
})
409+
}

0 commit comments

Comments
 (0)