Skip to content

Commit 8b0a19b

Browse files
committed
fix(kms_key_policy): add dynamic block for deploy role
1 parent 601187e commit 8b0a19b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,25 @@ data "aws_iam_policy_document" "kms_key_policy" {
143143
}
144144
}
145145

146+
dynamic "statement" {
147+
for_each = var.encrypt_with_kms && var.enable_deploy_role ? [1] : []
148+
content {
149+
sid = "Allow deploy user to use the CMK"
150+
actions = [
151+
"kms:GenerateDataKey*",
152+
"kms:Encrypt",
153+
"kms:Decrypt"
154+
]
155+
resources = ["*"]
156+
157+
principals {
158+
type = "AWS"
159+
identifiers = [aws_iam_role.deploy[0].arn]
160+
}
161+
effect = "Allow"
162+
}
163+
}
164+
146165
statement {
147166
sid = "Allow CloudFront usage of the key"
148167
effect = "Allow"

0 commit comments

Comments
 (0)