Skip to content

Commit 855e505

Browse files
Add access for new bors to PUT into artifacts bucket
This grants access under a new directory prefix (rustc-builds-try) as a temporary measure to avoid mistakes overwriting any actual artifacts. It might be a good idea in any case to scope try builds into a different bucket or place than real builds.
1 parent 4922a33 commit 855e505

File tree

3 files changed

+78
-7
lines changed

3 files changed

+78
-7
lines changed

terraform/rustc-ci/environments.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ module "public" {
55
aws.east1 = aws.east1
66
}
77

8-
iam_prefix = "ci--rust-lang--rust"
9-
repo = "rust-lang-ci/rust"
8+
iam_prefix = "ci--rust-lang--rust"
9+
repo = "rust-lang-ci/rust"
10+
source_repo = "rust-lang/rust"
1011

1112
caches_bucket = "rust-lang-ci-sccache2"
1213
caches_domain = "ci-caches.rust-lang.org"
@@ -17,7 +18,7 @@ module "public" {
1718

1819
delete_caches_after_days = 90
1920
delete_artifacts_after_days = 168
20-
response_policy_id = data.terraform_remote_state.shared.outputs.mdbook_response_policy
21+
response_policy_id = data.terraform_remote_state.shared.outputs.mdbook_response_policy
2122
}
2223

2324
module "security" {
@@ -27,13 +28,14 @@ module "security" {
2728
aws.east1 = aws.east1
2829
}
2930

30-
iam_prefix = "ci--rust-lang-ci--rsec"
31-
repo = "rust-lang-ci/rsec"
31+
iam_prefix = "ci--rust-lang-ci--rsec"
32+
repo = "rust-lang-ci/rsec"
33+
source_repo = "rust-lang-ci/rsec"
3234

3335
caches_bucket = "rust-lang-security-ci-caches"
3436
artifacts_bucket = "rust-lang-security-ci-artifacts"
3537

3638
delete_caches_after_days = 30
3739
delete_artifacts_after_days = 90
38-
response_policy_id = data.terraform_remote_state.shared.outputs.mdbook_response_policy
40+
response_policy_id = data.terraform_remote_state.shared.outputs.mdbook_response_policy
3941
}

terraform/rustc-ci/impl/_terraform.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ variable "repo" {
5656
type = string
5757
}
5858

59+
variable "source_repo" {
60+
description = "GitHub repository to authorize for roles"
61+
type = string
62+
}
63+
5964
variable "response_policy_id" {
6065
description = "CDN response policy"
61-
type = string
66+
type = string
6267
}

terraform/rustc-ci/impl/artifacts.tf

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,67 @@ resource "aws_s3_bucket_inventory" "artifacts" {
149149
}
150150
}
151151
}
152+
153+
resource "aws_iam_role" "try_builds" {
154+
name = "${var.iam_prefix}--try-role"
155+
156+
assume_role_policy = jsonencode({
157+
Version = "2012-10-17"
158+
Statement = [
159+
{
160+
Effect = "Allow"
161+
Action = "sts:AssumeRoleWithWebIdentity"
162+
Principal = {
163+
Federated = "arn:aws:iam::890664054962:oidc-provider/token.actions.githubusercontent.com"
164+
}
165+
Condition = {
166+
StringEquals = {
167+
"token.actions.githubusercontent.com:sub" = "repo:${var.repo}:ref:refs/heads/automation/bors/try"
168+
}
169+
}
170+
}
171+
]
172+
})
173+
174+
inline_policy {
175+
name = "put-objects"
176+
policy = jsonencode({
177+
Version = "2012-10-17"
178+
Statement = [
179+
{
180+
Sid = "ArtifactsBucketWrite"
181+
Effect = "Allow"
182+
Resource = [
183+
"${aws_s3_bucket.artifacts.arn}/rustc-builds-try",
184+
"${aws_s3_bucket.artifacts.arn}/rustc-builds-try/*",
185+
"${aws_s3_bucket.artifacts.arn}/rustc-builds-try-alt",
186+
"${aws_s3_bucket.artifacts.arn}/rustc-builds-try-alt/*",
187+
]
188+
Action = [
189+
"s3:GetObject",
190+
"s3:DeleteObject",
191+
"s3:PutObject",
192+
"s3:PutObjectAcl",
193+
]
194+
},
195+
{
196+
Sid = "ArtifactsBucketList"
197+
Effect = "Allow"
198+
Resource = "${aws_s3_bucket.artifacts.arn}"
199+
Action = [
200+
"s3:ListBucket",
201+
],
202+
},
203+
{
204+
Sid = "HeadBuckets",
205+
Effect = "Allow",
206+
Resource = "*"
207+
Action = [
208+
"s3:HeadBucket",
209+
"s3:GetBucketLocation",
210+
],
211+
},
212+
]
213+
})
214+
}
215+
}

0 commit comments

Comments
 (0)