-
Notifications
You must be signed in to change notification settings - Fork 628
/
policies-runner.tf
66 lines (55 loc) · 2.28 KB
/
policies-runner.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
data "aws_caller_identity" "current" {}
resource "aws_iam_role" "runner" {
name = "${var.prefix}-runner-role"
assume_role_policy = templatefile("${path.module}/policies/instance-role-trust-policy.json", {})
path = local.role_path
permissions_boundary = var.role_permissions_boundary
tags = local.tags
}
resource "aws_iam_instance_profile" "runner" {
name = "${var.prefix}-runner-profile"
role = aws_iam_role.runner.name
path = local.instance_profile_path
}
resource "aws_iam_role_policy" "runner_session_manager_aws_managed" {
name = "runner-ssm-session"
count = var.enable_ssm_on_runners ? 1 : 0
role = aws_iam_role.runner.name
policy = templatefile("${path.module}/policies/instance-ssm-policy.json", {})
}
resource "aws_iam_role_policy" "ssm_parameters" {
name = "runner-ssm-parameters"
role = aws_iam_role.runner.name
policy = templatefile("${path.module}/policies/instance-ssm-parameters-policy.json",
{
arn_ssm_parameters_prefix = "arn:${var.aws_partition}:ssm:${var.aws_region}:${data.aws_caller_identity.current.account_id}:parameter/${var.prefix}-*"
arn_ssm_parameters_path = "arn:${var.aws_partition}:ssm:${var.aws_region}:${data.aws_caller_identity.current.account_id}:parameter/${var.prefix}/*"
}
)
}
resource "aws_iam_role_policy" "dist_bucket" {
count = var.enable_runner_binaries_syncer ? 1 : 0
name = "distribution-bucket"
role = aws_iam_role.runner.name
policy = templatefile("${path.module}/policies/instance-s3-policy.json",
{
s3_arn = "${var.s3_runner_binaries.arn}/${var.s3_runner_binaries.key}"
}
)
}
resource "aws_iam_role_policy" "describe_tags" {
name = "runner-describe-tags"
role = aws_iam_role.runner.name
policy = file("${path.module}/policies/instance-describe-tags-policy.json")
}
resource "aws_iam_role_policy_attachment" "managed_policies" {
count = length(var.runner_iam_role_managed_policy_arns)
role = aws_iam_role.runner.name
policy_arn = element(var.runner_iam_role_managed_policy_arns, count.index)
}
resource "aws_iam_role_policy" "ec2" {
name = "ec2"
role = aws_iam_role.runner.name
policy = templatefile("${path.module}/policies/instance-ec2.json", {})
}
// see also logging.tf for logging and metrics policies