From 53b8950770e36ffedffa9b48b3a14e6257d4e133 Mon Sep 17 00:00:00 2001 From: Jeff Gran Date: Fri, 6 May 2022 11:18:14 -0600 Subject: [PATCH] Use ternary instead of && for boolean logic Logical binary operators don't short-circuit: https://github.com/hashicorp/terraform/issues/24128 --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 2fcd118..5bfa31b 100644 --- a/main.tf +++ b/main.tf @@ -10,9 +10,9 @@ locals { sqs_queue_name = length(var.sqs_queue_name) > 0 ? var.sqs_queue_name : "${var.prefix}-sqs-${random_id.uniq.hex}" sqs_queue_key_arn = var.sqs_encryption_enabled ? (length(var.sqs_encryption_key_arn) > 0 ? var.sqs_encryption_key_arn : aws_kms_key.lacework_kms_key[0].arn) : "" create_kms_key = ( - (!var.use_existing_cloudtrail && length(var.bucket_sse_key_arn) == 0) - || (var.sns_topic_encryption_enabled && length(var.sns_topic_encryption_key_arn) == 0) - || (var.sqs_encryption_enabled && length(var.sqs_encryption_key_arn) == 0) + (!var.use_existing_cloudtrail ? length(var.bucket_sse_key_arn) == 0) : false + || (var.sns_topic_encryption_enabled ? length(var.sns_topic_encryption_key_arn) == 0 : false) + || (var.sqs_encryption_enabled ? length(var.sqs_encryption_key_arn) == 0 : false) ) ? 1 : 0 cross_account_policy_name = ( length(var.cross_account_policy_name) > 0 ? var.cross_account_policy_name : "${var.prefix}-cross-acct-policy-${random_id.uniq.hex}"