From 482be0b564f0830a506b721186251cbd8168b883 Mon Sep 17 00:00:00 2001 From: Benjamin Smith Date: Thu, 15 Aug 2024 08:30:51 -0700 Subject: [PATCH] make requester vpc lookup optional if vpc is passed (#1099) --- modules/vpc-peering/main.tf | 2 +- modules/vpc-peering/remote-state.tf | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/vpc-peering/main.tf b/modules/vpc-peering/main.tf index c189b773e..00bccce7c 100644 --- a/modules/vpc-peering/main.tf +++ b/modules/vpc-peering/main.tf @@ -1,7 +1,7 @@ locals { enabled = module.this.enabled - requester_vpc_id = coalesce(var.requester_vpc_id, module.requester_vpc.outputs.vpc_id) + requester_vpc_id = coalesce(var.requester_vpc_id, one(module.requester_vpc[*].outputs.vpc_id)) accepter_aws_assume_role_arn = var.accepter_stage_name != null ? module.iam_roles.terraform_role_arns[var.accepter_stage_name] : var.accepter_aws_assume_role_arn } diff --git a/modules/vpc-peering/remote-state.tf b/modules/vpc-peering/remote-state.tf index 17a9d24ec..41ed05d07 100644 --- a/modules/vpc-peering/remote-state.tf +++ b/modules/vpc-peering/remote-state.tf @@ -1,4 +1,6 @@ module "requester_vpc" { + count = var.requester_vpc_id == null ? 1 : 0 + source = "cloudposse/stack-config/yaml//modules/remote-state" version = "1.5.0"