-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathiam_policies.tf
100 lines (88 loc) · 2.75 KB
/
iam_policies.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
######################
# Assume Role Policy #
######################
data "aws_iam_policy_document" "assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = [data.aws_caller_identity.current.account_id]
}
condition {
test = "Bool"
variable = "aws:MultiFactorAuthPresent"
values = ["true"]
}
}
}
#################
# Role Policies #
#################
data "aws_iam_policy_document" "billing_full_access" {
statement {
sid = "BillingFullAccessPermissions"
effect = "Allow"
actions = [
"aws-portal:*Billing",
"aws-portal:*Usage",
"aws-portal:*PaymentMethods",
"budgets:*Budget",
]
resources = ["*"]
}
}
resource "aws_iam_policy" "billing_full_access" {
name = "billing-full-access"
path = "/"
description = "Allows access to the 'billing-full-access' actions and resources."
policy = data.aws_iam_policy_document.billing_full_access.json
}
data "aws_iam_policy_document" "billing_view_access" {
statement {
sid = "BillingViewAccessPermissions"
effect = "Allow"
actions = [
"aws-portal:ViewPaymentMethods",
"aws-portal:ViewAccount",
"aws-portal:ViewBilling",
"aws-portal:ViewUsage",
"budgets:ViewBudget",
]
resources = ["*"]
}
}
resource "aws_iam_policy" "billing_view_access" {
name = "billing-view-access"
path = "/"
description = "Allows access to the 'billing-view-access' actions and resources."
policy = data.aws_iam_policy_document.billing_view_access.json
}
############################
# Role Assumption Policies #
############################
# Allow assuming the "billing_full_access" role
data "aws_iam_policy_document" "assume_role_billing_full_access_policy_doc" {
statement {
actions = ["sts:AssumeRole"]
resources = [aws_iam_role.billing_full_access.arn]
}
}
resource "aws_iam_policy" "assume_role_billing_full_access_policy" {
name = "billing-full-access-assume-role"
path = "/"
description = "Allows the 'billing-full-access' role to be assumed."
policy = data.aws_iam_policy_document.assume_role_billing_full_access_policy_doc.json
}
# Allow assuming the "billing_view_access" role
data "aws_iam_policy_document" "assume_role_billing_view_access_policy_doc" {
statement {
actions = ["sts:AssumeRole"]
resources = [aws_iam_role.billing_view_access.arn]
}
}
resource "aws_iam_policy" "assume_role_billing_view_access_policy" {
name = "billing-view-access-assume-role"
path = "/"
description = "Allows the 'billing-view-access' role to be assumed."
policy = data.aws_iam_policy_document.assume_role_billing_view_access_policy_doc.json
}