-
Notifications
You must be signed in to change notification settings - Fork 3
/
iam_groups.tf
42 lines (32 loc) · 1.18 KB
/
iam_groups.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
35
36
37
38
39
40
41
42
resource "aws_iam_group" "shepherd_users" {
name = "shepherd_users"
}
// Using a data resource validates that the users exist before applying
data "aws_iam_user" "shepherd_users" {
count = length(var.shepherd_users)
user_name = var.shepherd_users[count.index]
}
resource "aws_iam_group_membership" "shepherd_users" {
count = length(var.shepherd_users) > 0 ? 1 : 0
name = "shepherd_user_group_membership"
group = aws_iam_group.shepherd_users.name
users = data.aws_iam_user.shepherd_users[*].user_name
}
resource "aws_iam_group" "shepherd_engineers" {
name = "shepherd_engineers"
}
// Using a data resource validates that the engineers exist before applying
data "aws_iam_user" "shepherd_engineers" {
count = length(var.shepherd_engineers)
user_name = var.shepherd_engineers[count.index]
}
resource "aws_iam_group_membership" "shepherd_engineers" {
count = length(var.shepherd_engineers) > 0 ? 1 : 0
name = "shepherd_user_group_membership"
group = aws_iam_group.shepherd_engineers.name
users = data.aws_iam_user.shepherd_engineers[*].user_name
}
// Adding this for the redshift demo
resource "aws_iam_group" "shepherd_redshift" {
name = "shepherd_redshift"
}