Skip to content

Commit 8159bad

Browse files
committed
Add KMS encryption to topic
1 parent dacbe62 commit 8159bad

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

infra/batch_processor_errors_sns_topic.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
resource "aws_sns_topic" "batch_processor_errors" {
2-
name = "${var.environment}-batch-processor-errors"
2+
name = "${var.environment}-batch-processor-errors"
3+
kms_master_key_id = aws_kms_key.batch_processor_errors_sns_encryption_key.arn
34
}
45

56
resource "aws_sns_topic_policy" "batch_processor_errors_topic_policy" {

infra/kms.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,44 @@ resource "aws_kms_alias" "id_sync_sqs_encryption" {
179179
target_key_id = aws_kms_key.id_sync_sqs_encryption.key_id
180180
}
181181

182+
resource "aws_kms_key" "batch_processor_errors_sns_encryption_key" {
183+
description = "KMS key for encrypting the batch processor errors SNS Topic messages"
184+
deletion_window_in_days = 7
185+
enable_key_rotation = true
186+
187+
policy = jsonencode({
188+
Version = "2012-10-17"
189+
Statement = [
190+
local.policy_statement_allow_administration,
191+
{
192+
Effect = "Allow"
193+
Principal = {
194+
Service = "sns.amazonaws.com"
195+
}
196+
Action = ["kms:GenerateDataKey*", "kms:Decrypt"]
197+
Resource = "*"
198+
},
199+
{
200+
Effect = "Allow",
201+
Principal = {
202+
"Service": "cloudwatch.amazonaws.com"
203+
},
204+
Action = ["kms:GenerateDataKey*", "kms:Decrypt"],
205+
Resource = "*"
206+
},
207+
{
208+
Effect = "Allow",
209+
Principal = {
210+
"Service": "chatbot.amazonaws.com"
211+
},
212+
Action = ["kms:GenerateDataKey*", "kms:Decrypt"],
213+
Resource = "*"
214+
}
215+
]
216+
})
217+
}
218+
219+
resource "aws_kms_alias" "batch_processor_errors_sns_encryption_key" {
220+
name = "alias/${var.environment}-batch-processor-errors-imms-sns-encryption"
221+
target_key_id = aws_kms_key.batch_processor_errors_sns_encryption_key.key_id
222+
}

0 commit comments

Comments
 (0)