Refactor module structures
Problem
The current module pattern of passing in a list of things to create results in too many resource replacements, especially of group memberships. These wouldn't be a problem by themselves, except that each replacement results in emailing the end-user, which is annoying and confusing, as they get notifications about joining groups that they thought they were already in.
Proposal
Refactor the pattern across all modules in this repository so that each of them only takes one set of parameters, rather than a list of them, and move the looping to the caller, for example:
module "groups" {
groups = { for slug in local.group_slugs :
slug => {
name = try(local.groups[slug].name, slug)
...
}
}
}
would become:
module "groups" {
for_each = local.group_slugs
name = try(local.groups[each.key].name, each.key)
...
}
Then the module outputs could become flat items, rather than lists of maps that can't be resolved until after the entire module is created, even for items that aren't changing.