-
-
Save ahakimx/9fb59ac78358b524129152e8d29acd0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_iam_user" "admin_user" { | |
name = each.value | |
for_each = toset(var.admin_users) | |
tags = { | |
Description = "Tech Lead" | |
} | |
} | |
resource "aws_iam_group" "tech-lead" { | |
name = "Tech-Lead" | |
} | |
resource "aws_iam_group_membership" "team" { | |
name = "tech-lead-group-membership" | |
for_each = aws_iam_user.admin_user | |
users = [each.value.name] | |
group = aws_iam_group.tech-lead.name | |
} | |
resource "aws_iam_user_login_profile" "userLogin" { | |
for_each = aws_iam_user.admin_user | |
user = each.value.name | |
} | |
resource "aws_iam_policy" "adminUser" { | |
name = "AdminUsers" | |
policy = file("admin-policy.json") | |
} | |
# resource "aws_iam_user_policy_attachment" "admin-access" { | |
# for_each = aws_iam_user.admin_user | |
# user = each.value.name | |
# policy_arn = aws_iam_policy.adminUser.arn | |
# } | |
resource "aws_iam_group_policy_attachment" "tech_lead_group_policy" { | |
group = aws_iam_group.tech-lead.name | |
policy_arn = aws_iam_policy.adminUser.arn | |
} | |
output "password" { | |
value = { | |
for k, v in aws_iam_user_login_profile.userLogin : k => v.password | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment