I am trying to use the Conditional Block for terraform for creating aws iam groups and adding users into that groups based on count n length.
However the value of the iam user is a list and depends upon the environment value set by another value.
So this list is not passable by any iteration method in terraform.
Please check if anyone can help me out from HC family.
Code Snippet is shared below.
I want if the aws_env is NONPROD, one value should be used, if env is PROD, other value should be used.
module “iam_users” {
source = “…/modules/iam_users”
tf_state_s3_bucket = “aws-${lower(var.aws_env)}-tf-state”
tf_state_dynamodb = “aws-${lower(var.aws_env)}-tf-state”
aws_env = var.aws_env
iam_admin_users = var.iam_admin_users
}
variable “iam_admin_users” {
description = “List of Admin users to add to IAM”
type = list(string)
NONPROD = [
"abc@gmail.com",
"efg@gmail.com",
"ijk@gmail.com",
"mno@gmail.com",
"xyz@gmail.com"
]
PROD = [
"tap@gmail.com",
"pat@gmail.com",
]
}