From 2273f5685dffa20bceb2fe4629fb822a9ec9d805 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 25 May 2020 23:39:08 +0200 Subject: [PATCH] Fix a bug that created group membership resources for empty groups --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 79e666a..797e5ab 100644 --- a/main.tf +++ b/main.tf @@ -93,9 +93,9 @@ resource "aws_iam_user_policy_attachment" "policy" { ] } -# add the user to a list of groups +# add the user to a list of groups if groups are defined resource "aws_iam_user_group_membership" "group" { - for_each = var.module_enabled ? var.names : [] + for_each = var.module_enabled && length(var.groups) > 0 ? var.names : [] user = aws_iam_user.user[each.key].name groups = var.groups