-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.tf
50 lines (37 loc) · 1.17 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
resource "aws_iam_group" "this" {
name = var.name
path = var.path
}
###################################################
# IAM Policy for AssumeRole
###################################################
data "aws_iam_policy_document" "assume_role" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
resources = var.assumable_roles
}
}
resource "aws_iam_group_policy" "assume_role" {
count = length(var.assumable_roles) > 0 ? 1 : 0
group = aws_iam_group.this.id
name = "assume-role"
policy = data.aws_iam_policy_document.assume_role.json
}
###################################################
# IAM Policy Attachment for Managed Policies
###################################################
resource "aws_iam_group_policy_attachment" "managed" {
for_each = toset(var.policies)
group = aws_iam_group.this.id
policy_arn = each.key
}
###################################################
# IAM Policy Attachment for Inline Policies
###################################################
resource "aws_iam_group_policy" "inline" {
for_each = var.inline_policies
group = aws_iam_group.this.id
name = each.key
policy = each.value
}