We have a central folder that contains our IAM Modules. Each service has its own .tf file. Example:
ls service-roles/
roleA.tf roleB.tf roleC.tf
Then for a given environment such as dev, staging, prod, we have a terragrunt.hcl file that calls this module with inputs:
terraform {
source = run_cmd(
...
"service-roles/"
)
}
...
inputs = {
my_service_roles = {
roleA = ["xyz"]
roleB = ["abcd"]
roleC = ["mno"]
}
}
The challenge we face is if a developer now adds roleD, the inputs for dev, staging, and prod will also need to include roleD. I know that we could in theory version the module for every additional role added and then have each environment point at a given version. But, the issue is if you have many developers adding many roles, then some roles will be promoted on a different cadence from others. So, we’d still have the problem where there are missing inputs in some cases. For example, if roleD, roleE, roleF, roleG are added to dev at a similar time, we’d version the dev module. And then maybe only roleD, and roleE would be promoted, and so now we can’t have staging use the version of the module that includes roleF and role G.
TLDR: It’s confusing as to how to approach this problem where we have a role module that is used by many users, and those roles get promoted on different cadences from each other, which means the inputs get out of sync and cause Module Applies to break due to missing inputs with errors such as
This object does not have an attribute named "roleF".