From c27618640d1d76a04cdd6acbcb4a862af36aa6fd Mon Sep 17 00:00:00 2001 From: Vedant Pareek Date: Wed, 20 Mar 2024 14:24:55 +0530 Subject: [PATCH 1/2] Bug fix for len(azs) != len(subnets) --- efs.tf | 2 +- locals.tf | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/efs.tf b/efs.tf index 2934057..b604272 100644 --- a/efs.tf +++ b/efs.tf @@ -68,7 +68,7 @@ module "efs" { name = "${var.cluster_name}-efs" - mount_targets = { for k, v in zipmap(var.azs, var.private_subnets_id) : k => { subnet_id = v } } + mount_targets = local.mount_targets security_group_description = "${var.cluster_name} EFS" security_group_vpc_id = var.vpc_id attach_policy = true diff --git a/locals.tf b/locals.tf index ddd9460..fdd2341 100644 --- a/locals.tf +++ b/locals.tf @@ -1,3 +1,8 @@ +data "aws_subnet" "selected" { + count = length(var.private_subnets_id) + id = var.private_subnets_id[count.index] +} + locals { tags = merge( { @@ -7,4 +12,8 @@ locals { }, var.tags ) + subnets = merge({ for _, v in data.aws_subnet.selected : v.availability_zone => v.id... }) + mount_targets = merge({ for k, v in local.subnets : k => { + subnet_id = v[0] + } }) } \ No newline at end of file From 2966ef459322fb4b6676d2cbdda7a489ca9adf37 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 20 Mar 2024 08:56:24 +0000 Subject: [PATCH 2/2] terraform-docs: automated action --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d6a2bb2..f67e330 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Truefoundry AWS EFS Module |------|------| | [aws_iam_policy.efs](https://registry.terraform.io/providers/hashicorp/aws/5.17.0/docs/resources/iam_policy) | resource | | [aws_iam_policy_document.efs](https://registry.terraform.io/providers/hashicorp/aws/5.17.0/docs/data-sources/iam_policy_document) | data source | +| [aws_subnet.selected](https://registry.terraform.io/providers/hashicorp/aws/5.17.0/docs/data-sources/subnet) | data source | ## Inputs