-
Notifications
You must be signed in to change notification settings - Fork 1
/
policies.tf
125 lines (99 loc) · 3.52 KB
/
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# The policy document that allows assumption of the assessment roles
# needed in order to provision assessment environments.
data "aws_iam_policy_document" "provision_assessment_base" {
statement {
actions = [
"sts:AssumeRole",
"sts:TagSession",
]
# For an extra layer of security, we check that the role has been
# properly tagged as "AssessmentAccount == true".
condition {
test = "StringEquals"
values = [
"true",
]
variable = "aws:ResourceTag/AssessmentAccount"
}
effect = "Allow"
resources = [
"arn:aws:iam::*:role/${var.provision_assessment_role_name}",
"arn:aws:iam::*:role/${var.startstopssmsession_role_name}",
]
sid = "AllowAssessmentAccountRoles"
}
}
# The policy document that allows assumption of all non-assessment
# roles needed in order to provision assessment environments. It also
# specifically denies assumption of non-required non-assessment
# account provisioning roles.
data "aws_iam_policy_document" "provision_assessment_backend" {
statement {
actions = [
"sts:AssumeRole",
"sts:TagSession",
]
effect = "Allow"
resources = local.required_non_assessment_roles_backend
sid = "AllowRequiredNonAssessmentAccountRoles"
}
statement {
actions = [
"sts:AssumeRole",
"sts:TagSession",
]
effect = "Deny"
resources = local.prohibited_non_assessment_roles_backend
sid = "DenyNonAssessmentAccountRoles"
}
}
# The policy document that allows assumption of all non-assessment
# roles needed in order to provision assessment environments with the
# exception of Terraform backend access. It also specifically denies
# assumption of non-required non-assessment account provisioning
# roles.
data "aws_iam_policy_document" "provision_assessment_no_backend" {
statement {
actions = [
"sts:AssumeRole",
"sts:TagSession",
]
effect = "Allow"
resources = local.required_non_assessment_roles_no_backend
sid = "AllowRequiredNonAssessmentAccountRolesNoBackend"
}
statement {
actions = [
"sts:AssumeRole",
"sts:TagSession",
]
effect = "Deny"
resources = local.prohibited_non_assessment_roles_no_backend
sid = "DenyNonAssessmentAccountRolesNoBackend"
}
}
# The policy that allows assumption of all assessment roles needed in
# order to provision assessment environments.
resource "aws_iam_policy" "provision_assessment_base" {
provider = aws.users
description = var.provision_assessment_base_policy_description
name = var.provision_assessment_base_policy_name
policy = data.aws_iam_policy_document.provision_assessment_base.json
}
# The policy that allows assumption of all non-assessment roles needed
# in order to provision assessment environments.
resource "aws_iam_policy" "provision_assessment_backend" {
provider = aws.users
description = var.provision_assessment_backend_policy_description
name = var.provision_assessment_backend_policy_name
policy = data.aws_iam_policy_document.provision_assessment_backend.json
}
# The policy that allows assumption of all non-assessment roles needed
# in order to provision assessment environments with the exception of
# Terraform backend access.
resource "aws_iam_policy" "provision_assessment_no_backend" {
provider = aws.users
description = var.provision_assessment_no_backend_policy_description
name = var.provision_assessment_no_backend_policy_name
policy = data.aws_iam_policy_document.provision_assessment_no_backend.json
}