Skip to content

Commit 5e92af8

Browse files
authored
Merge pull request #666 from rust-lang/rustc-ci-rust-lang-rust
provision aws tokens for rust-lang/rust
2 parents 3bfc465 + ff0e491 commit 5e92af8

File tree

13 files changed

+684
-1
lines changed

13 files changed

+684
-1
lines changed

terragrunt/accounts/legacy/rustc-ci-prod/.terraform.lock.hcl

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
terraform {
2+
source = "../../../modules//rustc-ci"
3+
}
4+
5+
include {
6+
path = find_in_parent_folders()
7+
merge_strategy = "deep"
8+
}
9+
10+
inputs = {
11+
repo = "rust"
12+
caches_bucket = "rust-lang-ci-sccache2"
13+
artifacts_bucket = "rust-lang-ci2"
14+
artifacts_domain = "ci-artifacts.rust-lang.org"
15+
caches_domain = "ci-caches.rust-lang.org"
16+
inventories_bucket = "rust-inventories"
17+
}

terragrunt/accounts/legacy/rustc-ci-staging/.terraform.lock.hcl

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
source = "../../../modules//rustc-ci"
3+
}
4+
5+
include {
6+
path = find_in_parent_folders()
7+
merge_strategy = "deep"
8+
}
9+
10+
inputs = {
11+
repo = "bors-kindergarten"
12+
}

terragrunt/modules/gha-iam-user/main.tf

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
github = {
44
source = "integrations/github"
5-
version = "~> 6.2.3"
5+
version = "~> 6.2"
66
}
77
}
88
}
@@ -19,14 +19,34 @@ resource "aws_iam_access_key" "ci" {
1919
user = aws_iam_user.ci.name
2020
}
2121

22+
# Create repository secrets if the variable `environment` is not specified
2223
resource "github_actions_secret" "aws_access_key_id" {
24+
count = var.environment == null ? 1 : 0
2325
repository = var.repo
2426
secret_name = "${var.env_prefix != null ? "${var.env_prefix}_" : ""}AWS_ACCESS_KEY_ID"
2527
plaintext_value = aws_iam_access_key.ci.id
2628
}
2729

2830
resource "github_actions_secret" "aws_secret_access_key" {
31+
count = var.environment == null ? 1 : 0
2932
repository = var.repo
3033
secret_name = "${var.env_prefix != null ? "${var.env_prefix}_" : ""}AWS_SECRET_ACCESS_KEY"
3134
plaintext_value = aws_iam_access_key.ci.secret
3235
}
36+
37+
# Create environment secrets if `environment` is specified
38+
resource "github_actions_environment_secret" "aws_access_key_id" {
39+
count = var.environment != null ? 1 : 0
40+
repository = var.repo
41+
environment = var.environment
42+
secret_name = "${var.env_prefix != null ? "${var.env_prefix}_" : ""}AWS_ACCESS_KEY_ID"
43+
plaintext_value = aws_iam_access_key.ci.id
44+
}
45+
46+
resource "github_actions_environment_secret" "aws_secret_access_key" {
47+
count = var.environment != null ? 1 : 0
48+
repository = var.repo
49+
environment = var.environment
50+
secret_name = "${var.env_prefix != null ? "${var.env_prefix}_" : ""}AWS_SECRET_ACCESS_KEY"
51+
plaintext_value = aws_iam_access_key.ci.secret
52+
}

terragrunt/modules/gha-iam-user/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ variable "env_prefix" {
1919
default = null
2020
description = "Prefix the environment variables in GitHub Actions should have"
2121
}
22+
23+
variable "environment" {
24+
type = string
25+
default = null
26+
description = "The name of the GitHub environment where GitHub Actions environment secrets are stored. If omitted, GitHub Actions repository secrets are created instead."
27+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
terraform {
2+
required_version = "~> 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 5.86"
8+
}
9+
10+
github = {
11+
source = "integrations/github"
12+
version = "~> 6.2"
13+
}
14+
}
15+
}
16+
17+
provider "github" {
18+
owner = "rust-lang"
19+
}
20+
21+
data "terraform_remote_state" "shared" {
22+
backend = "s3"
23+
config = {
24+
bucket = "rust-terraform"
25+
key = "simpleinfra/shared.tfstate"
26+
region = "us-west-1"
27+
}
28+
}
29+
30+
variable "repo" {
31+
description = "GitHub repository to authorize. E.g. `rust`. GitHub org is hardcoded to `rust-lang`."
32+
type = string
33+
validation {
34+
condition = !can(regex("/", var.repo))
35+
error_message = "The repo variable must not contain `/`. Only provide the repository name."
36+
}
37+
validation {
38+
condition = length(var.repo) > 0
39+
error_message = "The repo variable must not be empty."
40+
}
41+
}
42+
43+
variable "artifacts_bucket" {
44+
description = "ID of the S3 bucket to store build artifacts. If unspecified, it is automatically generated, based on the repo name."
45+
type = string
46+
default = null
47+
validation {
48+
condition = var.artifacts_bucket == null ? true : length(var.artifacts_bucket) > 0
49+
error_message = "The artifacts_bucket variable must not be empty when specified."
50+
}
51+
}
52+
53+
variable "inventories_bucket" {
54+
description = "ID of the S3 bucket to store rust inventories. If unspecified, it is automatically generated, based on the repo name."
55+
type = string
56+
default = null
57+
validation {
58+
condition = var.inventories_bucket == null ? true : length(var.inventories_bucket) > 0
59+
error_message = "The inventories_bucket variable must not be empty when specified."
60+
}
61+
}
62+
63+
variable "caches_bucket" {
64+
description = "ID of the S3 bucket to store caches. If unspecified, it is automatically generated, based on the repo name."
65+
type = string
66+
default = null
67+
validation {
68+
condition = var.caches_bucket == null ? true : length(var.caches_bucket) > 0
69+
error_message = "The caches_bucket variable must not be empty when specified."
70+
}
71+
}
72+
73+
variable "artifacts_domain" {
74+
description = "Domain name for the CloudFront distribution in front of the artifacts bucket. If unspecified, it is automatically generated, based on the repo name."
75+
type = string
76+
default = null
77+
validation {
78+
condition = var.artifacts_domain == null ? true : length(var.artifacts_domain) > 0
79+
error_message = "The artifacts_domain variable must not be empty when specified."
80+
}
81+
}
82+
83+
variable "caches_domain" {
84+
description = "Domain name for the CloudFront distribution in front of the caches bucket. If unspecified, it is automatically generated, based on the repo name."
85+
type = string
86+
default = null
87+
validation {
88+
condition = var.caches_domain == null ? true : length(var.caches_domain) > 0
89+
error_message = "The caches_domain variable must not be empty when specified."
90+
}
91+
}

0 commit comments

Comments
 (0)