From aa9a0050c31382beef559c55f6cc05f1b4fd548d Mon Sep 17 00:00:00 2001 From: Joao C Costa Date: Sat, 23 Sep 2023 13:29:31 +0100 Subject: [PATCH] aws_caller_identity and aws_partition allocated only if needed --- main.tf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.tf b/main.tf index 5a2db6e..69608ca 100644 --- a/main.tf +++ b/main.tf @@ -87,14 +87,18 @@ resource "helm_release" "this" { # IAM Role for Service Account(s) (IRSA) ################################################################################ -data "aws_partition" "current" {} -data "aws_caller_identity" "current" {} +data "aws_partition" "current" { + count = var.create ? 1 : 0 +} +data "aws_caller_identity" "current" { + count = var.create ? 1 : 0 +} locals { create_role = var.create && var.create_role - account_id = data.aws_caller_identity.current.account_id - partition = data.aws_partition.current.partition + account_id = data.aws_caller_identity[0].current.account_id + partition = data.aws_partition[0].current.partition role_name = try(coalesce(var.role_name, var.name), "") role_name_condition = var.role_name_use_prefix ? "${local.role_name}-*" : local.role_name