Skip to content

Commit

Permalink
Merge pull request #4 from truefoundry/mount-targets-fix
Browse files Browse the repository at this point in the history
Bug fix for len(azs) != len(subnets)
  • Loading branch information
dunefro authored Mar 20, 2024
2 parents 71a3be2 + 2966ef4 commit 574d668
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion efs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
data "aws_subnet" "selected" {
count = length(var.private_subnets_id)
id = var.private_subnets_id[count.index]
}

locals {
tags = merge(
{
Expand All @@ -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]
} })
}

0 comments on commit 574d668

Please sign in to comment.