Hello, not sure if this is correct forum to place issues in but I am running into an issue when trying to add users to specific group. The group is successfully created, the users are successfully created, but when trying to add users to group it does not work. Is there something that I am doing wrong is is this a bug? I get the following error:
Terraform v0.12.24
Error
Error: Incorrect attribute value type
on: main.tf line 46, in resource "aws_iam_group_membership" "team":
46: users = each.key
Inappropriate value for attribute "users": set of string required.
terraform.tfvars
user_names = {
"dummy1" = {
path = "/"
force_destroy = true
tag_fullname = "dummy 1"
}
"dummy2" = {
path = "/"
force_destroy = true
tag_fullname = "dummy 2"
}
}
group_memberships = {
"dummy1" = ["dummy-group"]
"dummy2" = ["dummy-group"]
}
group = "dummy-group"
modules main.tf
### --------------------------------------
### Create user account
### --------------------------------------
resource "aws_iam_user" "username" {
for_each = var.user_names
name = each.key
path = each.value["path"]
force_destroy = each.value["force_destroy"]
# Full Name is tag Key, and each.value["tag_fullname"] is tag value
tags = map("Full Name", each.value["tag_fullname"])
}
### --------------------------------------
### Add user to group
### --------------------------------------
resource "aws_iam_group_membership" "team" {
name = var.group
for_each = var.group_memberships
users = each.key
group = each.value
depends_on = [aws_iam_user.username]
}