-
Notifications
You must be signed in to change notification settings - Fork 6
/
kms.tf
30 lines (29 loc) · 906 Bytes
/
kms.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
data "aws_iam_policy_document" "kms_policy_sns" {
count = var.sns_kms_encryption ? 1 : 0
statement {
sid = "Enable IAM User Permissions"
effect = "Allow"
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
}
actions = ["kms:*"]
resources = ["*"]
}
statement {
actions = ["kms:Decrypt", "kms:GenerateDataKey*"]
principals {
type = "Service"
identifiers = ["cloudwatch.amazonaws.com", "lambda.amazonaws.com"]
}
resources = ["*"]
sid = "allow-services-kms"
}
}
resource "aws_kms_key" "sns" {
count = var.sns_kms_encryption ? 1 : 0
deletion_window_in_days = 7
description = "SNS CMK Encryption Key"
enable_key_rotation = true
policy = data.aws_iam_policy_document.kms_policy_sns[0].json
}