File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change 22# SNS: topic & subscription
33#
44resource "aws_sns_topic" "cloudwatch_warning" {
5- name = " gc-design-system-cloudwatch-alarms-warning"
5+ name = " gc-design-system-cloudwatch-alarms-warning"
6+ kms_master_key_id = aws_kms_key. sns_cloudwatch . id
67
78 tags = {
89 CostCentre = var.billing_code
@@ -14,4 +15,42 @@ resource "aws_sns_topic_subscription" "alert_warning" {
1415 topic_arn = aws_sns_topic. cloudwatch_warning . arn
1516 protocol = " https"
1617 endpoint = var. slack_webhook_url
18+ }
19+
20+ # KMS Key for SNS CloudWatch topic
21+ # This key is used to encrypt messages sent to the SNS topic for CloudWatch alarms.
22+ resource "aws_kms_key" "sns_cloudwatch" {
23+ # checkov:skip=CKV_AWS_7: key rotation not required for CloudWatch SNS topic's messages
24+ description = " KMS key for CloudWatch SNS topic"
25+ policy = data. aws_iam_policy_document . sns_cloudwatch . json
26+ }
27+
28+ # IAM policy document for the KMS key used by SNS CloudWatch topic
29+ data "aws_iam_policy_document" "sns_cloudwatch" {
30+ # checkov:skip=CKV_AWS_109: `resources = ["*"]` identifies the KMS key to which the key policy is attached
31+ # checkov:skip=CKV_AWS_111: `resources = ["*"]` identifies the KMS key to which the key policy is attached
32+ statement {
33+ effect = " Allow"
34+ resources = [" *" ]
35+ actions = [" kms:*" ]
36+
37+ principals {
38+ type = " AWS"
39+ identifiers = [" arn:aws:iam::${ var . account_id } :root" ]
40+ }
41+ }
42+
43+ statement {
44+ effect = " Allow"
45+ resources = [" *" ]
46+ actions = [
47+ " kms:Decrypt" ,
48+ " kms:GenerateDataKey*" ,
49+ ]
50+
51+ principals {
52+ type = " Service"
53+ identifiers = [" cloudwatch.amazonaws.com" ]
54+ }
55+ }
1756}
You can’t perform that action at this time.
0 commit comments