Support map users and roles to multiple groups (#424)

* Support map users and roles to multiple groups

* Simplify code by rename `user_arn` to `userarn`, `role_arn` to `rolearn`

* Next version should be 6.x because PR this is a breaking change.

* Update example variables.tf

* Change indent to 2

* Fix map-aws-auth.yaml maybe invalid yaml.
This commit is contained in:
刘相轩
2019-08-19 22:15:01 +08:00
committed by Max Williams
parent b8b3b5820e
commit 8580b67813
8 changed files with 42 additions and 66 deletions

View File

@@ -95,46 +95,8 @@ data "template_file" "config_map_aws_auth" {
),
),
)
map_users = join("", data.template_file.map_users.*.rendered)
map_roles = join("", data.template_file.map_roles.*.rendered)
map_accounts = join("", data.template_file.map_accounts.*.rendered)
map_users = yamlencode(var.map_users),
map_roles = yamlencode(var.map_roles),
map_accounts = yamlencode(var.map_accounts)
}
}
data "template_file" "map_users" {
count = length(var.map_users)
template = file(
"${path.module}/templates/config-map-aws-auth-map_users.yaml.tpl",
)
vars = {
user_arn = var.map_users[count.index]["user_arn"]
username = var.map_users[count.index]["username"]
group = var.map_users[count.index]["group"]
}
}
data "template_file" "map_roles" {
count = length(var.map_roles)
template = file(
"${path.module}/templates/config-map-aws-auth-map_roles.yaml.tpl",
)
vars = {
role_arn = var.map_roles[count.index]["role_arn"]
username = var.map_roles[count.index]["username"]
group = var.map_roles[count.index]["group"]
}
}
data "template_file" "map_accounts" {
count = length(var.map_accounts)
template = file(
"${path.module}/templates/config-map-aws-auth-map_accounts.yaml.tpl",
)
vars = {
account_number = var.map_accounts[count.index]
}
}