forked from wardviaene/terraform-course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
28 lines (27 loc) · 902 Bytes
/
iam.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
# group definition
resource "aws_iam_group" "administrators" {
name = "administrators"
}
resource "aws_iam_policy_attachment" "administrators-attach" {
name = "administrators-attach"
groups = ["${aws_iam_group.administrators.name}"]
policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
}
# user
resource "aws_iam_user" "admin1" {
name = "admin1"
}
resource "aws_iam_user" "admin2" {
name = "admin2"
}
resource "aws_iam_group_membership" "administrators-users" {
name = "administrators-users"
users = [
"${aws_iam_user.admin1.name}",
"${aws_iam_user.admin2.name}",
]
group = "${aws_iam_group.administrators.name}"
}
output "warning" {
value = "WARNING: make sure you're not using the AdministratorAccess policy for other users/groups/roles. If this is the case, don't run terraform destroy, but manually unlink the created resources"
}