-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathartifacts.tf
79 lines (76 loc) · 2.04 KB
/
artifacts.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
// It would be even better if we could create these policies on demand
// before booting up a new runner and have them limited to runner ID prefix,
// but for that we would need to modify the scale up lambda function
// which is beyond the scope for now.
resource "aws_iam_role_policy" "artifacts_v2" {
for_each = local.runners
name = "${var.name}-${each.key}"
role = each.value.role_runner_id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "AllowLimitedGetPut"
Action = [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
"s3:PutObjectAcl",
]
Effect = "Allow"
Resource = ["${data.aws_s3_bucket.custom-github-runners.arn}/${each.key}/*"]
},
{
Sid = "AllowLimitedList"
Action = [
"s3:ListBucket",
]
Effect = "Allow"
Resource = ["${data.aws_s3_bucket.custom-github-runners.arn}"]
Condition = {
StringLike: {
"s3:prefix" = [
"${each.key}/*",
]
}
}
},
]
})
}
# resource "aws_iam_role_policy" "artifacts" {
# for_each = local.legacy_runners
# name = "${var.name}-${each.key}"
# role = each.value.role_runner_id
# policy = jsonencode({
# Version = "2012-10-17"
# Statement = [
# {
# Sid = "AllowLimitedGetPut"
# Action = [
# "s3:GetObject",
# "s3:GetObjectAcl",
# "s3:PutObject",
# "s3:PutObjectAcl",
# ]
# Effect = "Allow"
# Resource = ["${data.aws_s3_bucket.custom-github-runners.arn}/${each.key}/*"]
# },
# {
# Sid = "AllowLimitedList"
# Action = [
# "s3:ListBucket",
# ]
# Effect = "Allow"
# Resource = ["${data.aws_s3_bucket.custom-github-runners.arn}"]
# Condition = {
# StringLike: {
# "s3:prefix" = [
# "${each.key}/*",
# ]
# }
# }
# },
# ]
# })
# }