Skip to content

Commit bd01c53

Browse files
add support to empty kms key
1 parent 29ed445 commit bd01c53

File tree

1 file changed

+3
-3
lines changed
  • modules/integrations/cloud-logs

1 file changed

+3
-3
lines changed

modules/integrations/cloud-logs/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ locals {
6969
is_cross_account = var.bucket_account_id != null && var.bucket_account_id != data.aws_caller_identity.current.account_id
7070

7171
# KMS variables
72-
kms_account_id = split(":", var.kms_key_arn)[3]
73-
need_kms_policy = var.bucket_account_id != null && var.bucket_account_id != local.kms_account_id
72+
kms_account_id = var.kms_key_arn != null && var.kms_key_arn != "" ? split(":", var.kms_key_arn)[3] : null
73+
need_kms_policy = var.bucket_account_id != null && local.kms_account_id != null && var.bucket_account_id != local.kms_account_id
7474

7575
# Role variables
7676
role_name = split("/", var.role_arn)[1]
@@ -152,7 +152,7 @@ data "aws_iam_policy_document" "cloudlogs_s3_access" {
152152
}
153153

154154
dynamic "statement" {
155-
for_each = var.kms_key_arn != null ? [1] : []
155+
for_each = var.kms_key_arn != null && var.kms_key_arn != "" ? [1] : []
156156
content {
157157
sid = "CloudlogsKMSDecrypt"
158158

0 commit comments

Comments
 (0)