This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
policies.tf
86 lines (72 loc) · 2.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
resource "aws_iam_instance_profile" "instance" {
name = "gitlab-runner-instance-profile"
role = aws_iam_role.instance.name
}
data "template_file" "instance_role_trust_policy" {
template = file(
"${path.module}/policies/instance-role-trust-policy.json"
)
}
resource "aws_iam_role" "instance" {
name = "gitlab-runner-instance-role"
assume_role_policy = data.template_file.instance_role_trust_policy.rendered
}
data "template_file" "instance_session_manager_policy" {
template = file(
"${path.module}/policies/instance-session-manager-policy.json",
)
}
resource "aws_iam_policy" "instance_session_manager_policy" {
name = "gitlab-runner-session-manager"
path = "/"
description = "Policy for session manager"
policy = data.template_file.instance_session_manager_policy.rendered
}
resource "aws_iam_role_policy_attachment" "instance_session_manager_policy" {
role = aws_iam_role.instance.name
policy_arn = aws_iam_policy.instance_session_manager_policy.arn
}
resource "aws_iam_role_policy_attachment" "instance_session_manager_aws_managed" {
role = aws_iam_role.instance.name
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
}
data "template_file" "service_linked_role" {
template = file(
"${path.module}/policies/service-linked-role-create-policy.json"
)
}
resource "aws_iam_policy" "service_linked_role" {
name = "gitlab-runner-service_linked_role"
path = "/"
description = "Policy for creation of service linked roles"
policy = data.template_file.service_linked_role.rendered
}
resource "aws_iam_role_policy_attachment" "service_linked_role" {
role = aws_iam_role.instance.name
policy_arn = aws_iam_policy.service_linked_role.arn
}
data "template_file" "ssm_policy" {
template = file(
"${path.module}/policies/instance-secure-parameter-role-policy.json",
)
}
resource "aws_iam_policy" "ssm" {
name = "gitlab-runner-ssm"
path = "/"
description = "Policy for runner token param access via SSM"
policy = data.template_file.ssm_policy.rendered
}
resource "aws_iam_role_policy_attachment" "ssm" {
role = aws_iam_role.instance.name
policy_arn = aws_iam_policy.ssm.arn
}
data "template_file" "instance_profile" {
template = file(
"${path.module}/policies/instance-logging-policy.json"
)
}
resource "aws_iam_role_policy" "instance" {
name = "gitlab-runner-instance-role"
role = aws_iam_role.instance.name
policy = data.template_file.instance_profile.rendered
}