-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
34 lines (27 loc) · 928 Bytes
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
resource "aws_iam_user" "user" {
for_each = var.users
name = each.key
path = each.value["path"]
force_destroy = each.value["force_destroy"]
tags = map("EmailAddress", each.value["tag_email"])
}
resource "aws_iam_access_key" "credentials" {
for_each = var.users
user = each.key
depends_on = [
aws_iam_user.user,
]
}
resource "aws_secretsmanager_secret" "credentials" {
for_each = var.users
name = each.key
description = "credentials for ${each.key}"
}
resource "aws_secretsmanager_secret_version" "credentials" {
for_each = var.users
secret_id = aws_secretsmanager_secret.credentials[each.key].id
secret_string = jsonencode({"AccessKey" = aws_iam_access_key.credentials[each.key].id, "SecretAccessKey" = aws_iam_access_key.credentials[each.key].secret})
depends_on = [
aws_secretsmanager_secret.credentials,
]
}