forked from cisagov/cool-assessment-provisioner-iam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolicies.tf
66 lines (52 loc) · 1.6 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
# The policy document that allows assumption of all 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" {
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"
}
statement {
actions = [
"sts:AssumeRole",
"sts:TagSession",
]
effect = "Allow"
resources = local.required_non_assessment_roles
sid = "AllowRequiredNonAssessmentAccountRoles"
}
statement {
actions = [
"sts:AssumeRole",
"sts:TagSession",
]
effect = "Deny"
resources = local.prohibited_non_assessment_roles
sid = "DenyNonAssessmentAccountRoles"
}
}
# The policy that allows assumption of all roles needed in order to provision
# assessment environments.
resource "aws_iam_policy" "provision_assessment" {
provider = aws.users
description = var.provision_assessment_policy_description
name = var.provision_assessment_policy_name
policy = data.aws_iam_policy_document.provision_assessment.json
}