Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: secondary_gids ignored in acces point creation #85

Closed
wants to merge 15 commits into from
26 changes: 26 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ module "efs" {
region = var.region
vpc_id = module.vpc.vpc_id
subnets = module.subnets.private_subnet_ids
access_points = {
"data" = {
posix_user = {
gid = "1001"
uid = "5000"
secondary_gids = "1002,1003"
}
creation_info = {
gid = "1001"
uid = "5000"
permissions = "0755"
}
}
"data2" = {
posix_user = {
gid = "2001"
uid = "6000"
secondary_gids = null
}
creation_info = {
gid = "123"
uid = "222"
permissions = "0555"
}
}
}
security_group_rules = [
{
type = "egress"
Expand Down
7 changes: 6 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
locals {
dns_name = "${join("", aws_efs_file_system.default.*.id)}.efs.${var.region}.amazonaws.com"
security_group_enabled = module.this.enabled && var.security_group_enabled

secondary_gids = {
for k, v in var.access_points :
k => lookup(lookup(var.access_points[k], "posix_user", {}), "secondary_gids", null)
}
}

resource "aws_efs_file_system" "default" {
Expand Down Expand Up @@ -42,7 +47,7 @@ resource "aws_efs_access_point" "default" {
gid = var.access_points[each.key]["posix_user"]["gid"]
uid = var.access_points[each.key]["posix_user"]["uid"]
# Just returning null in the lookup function gives type errors and is not omitting the parameter, this work around ensures null is returned.
secondary_gids = lookup(lookup(var.access_points[each.key], "posix_user", {}), "secondary_gids", null) == null ? null : null
secondary_gids = local.secondary_gids[each.key] != null ? split(",", local.secondary_gids[each.key]) : null
}

root_directory {
Expand Down