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"