Skip to content

Commit 8b46a12

Browse files
feat: add support for GitHub and gitlab in helper (#1442)
Co-authored-by: Duda Martins <109083465+mariammartins@users.noreply.github.com>
1 parent bd6a4cd commit 8b46a12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2395
-697
lines changed

0-bootstrap/README-GitHub.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,9 @@ You must be [authenticated to GitHub](https://docs.github.com/en/authentication/
148148
cd ./envs/shared
149149
```
150150

151-
1. In the versions file `./versions.tf` un-comment the `github` required provider
152-
1. In the variables file `./variables.tf` un-comment variables in the section `Specific to github_bootstrap`
153-
1. In the outputs file `./outputs.tf` Comment-out outputs in the section `Specific to cloudbuild_module`
154-
1. In the outputs file `./outputs.tf` un-comment outputs in the section `Specific to github_bootstrap`
155-
1. Rename file `./cb.tf` to `./cb.tf.example`
156-
157-
```bash
158-
mv ./cb.tf ./cb.tf.example
159-
```
160-
161-
1. Rename file `./github.tf.example` to `./github.tf`
162-
151+
1. Run the helper script `choose_build_type.sh` to enable Bootstrap GitHub version
163152
```bash
164-
mv ./github.tf.example ./github.tf
153+
./scripts/choose_build_type.sh github
165154
```
166155

167156
1. Rename file `terraform.example.tfvars` to `terraform.tfvars`

0-bootstrap/README-GitLab.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ It is a best practice to have two separate projects here (`prj-b-seed` and `prj-
88
On one hand, `prj-b-seed` stores terraform state and has the Service Accounts able to create / modify infrastructure.
99
On the other hand, the authentication infrastructure using [Workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation) is implemented in `prj-b-cicd-wif-gl`.
1010

11+
## Requirements
12+
1113
To run the instructions described in this document, install the following:
1214

1315
- [Google Cloud SDK](https://cloud.google.com/sdk/install) version 393.0.0 or later
@@ -216,20 +218,9 @@ Run the `0-bootstrap/scripts/git_create_branches_helper.sh` script to create the
216218
cd ./envs/shared
217219
```
218220

219-
1. In the versions file `./versions.tf` un-comment the `gitlab` required provider
220-
1. In the variables file `./variables.tf` un-comment variables in the section `Specific to gitlab_bootstrap`
221-
1. In the outputs file `./outputs.tf` Comment-out outputs in the section `Specific to cloudbuild_module`
222-
1. In the outputs file `./outputs.tf` un-comment outputs in the section `Specific to gitlab_bootstrap`
223-
1. Rename file `./cb.tf` to `./cb.tf.example`
224-
225-
```bash
226-
mv ./cb.tf ./cb.tf.example
227-
```
228-
229-
1. Rename file `./gitlab.tf.example` to `./gitlab.tf`
230-
221+
1. Run the helper script `choose_build_type.sh` to enable Bootstrap GitLab version
231222
```bash
232-
mv ./gitlab.tf.example ./gitlab.tf
223+
./scripts/choose_build_type.sh gitlab
233224
```
234225

235226
1. Rename file `terraform.example.tfvars` to `terraform.tfvars`

0-bootstrap/README-Jenkins.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,11 @@ You arrived to these instructions because you are using the `jenkins_bootstrap`
139139
cd ./envs/shared
140140
```
141141

142-
1. Activate the Jenkins module and disable the Cloud Build module. This implies manually editing the following files:
143-
1. Rename file `./cb.tf` to `./cb.tf.example`
144-
145-
```bash
146-
mv ./cb.tf ./cb.tf.example
147-
```
148-
149-
1. Rename file `./jenkins.tf.example` to `./jenkins.tf`
150-
142+
1. Run the helper script `choose_build_type.sh` to enable Bootstrap Jenkins version
151143
```bash
152-
mv ./jenkins.tf.example ./jenkins.tf
144+
./scripts/choose_build_type.sh jenkins
153145
```
154146

155-
1. Un-comment the `jenkins_bootstrap` variables in `./variables.tf`
156-
1. Un-comment the `jenkins_bootstrap` outputs in `./outputs.tf`
157-
1. Comment-out the `cloudbuild_bootstrap` outputs in `./outputs.tf`
158147
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment.
159148

160149
```bash

0-bootstrap/README-Terraform-Cloud.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,9 @@ You must be authenticated to the VCS provider. See [GitHub authentication](https
136136
cd ./envs/shared
137137
```
138138

139-
1. In the versions file `./versions.tf` un-comment the `tfe` required provider
140-
1. In the variables file `./variables.tf` un-comment variables in the section `Specific to tfc_bootstrap`
141-
1. In the outputs file `./outputs.tf` Comment-out outputs in the section `Specific to cloudbuild_module`
142-
1. In the outputs file `./outputs.tf` un-comment outputs in the section `Specific to tfc_bootstrap`
143-
1. If you want to use [Terraform Cloud with Agents](https://developer.hashicorp.com/terraform/cloud-docs/agents), in addition to `Specific to tfc_bootstrap`, un-comment outputs in the section `Specific to tfc_bootstrap with Terraform Cloud Agents` and update `enable_tfc_cloud_agents` to `true` variable at `terraform.tfvars`
144-
1. Rename file `./cb.tf` to `./cb.tf.example`
145-
146-
```bash
147-
mv ./cb.tf ./cb.tf.example
148-
```
149-
150-
1. Rename file `.terraform_cloud.tf.example` to `./terraform_cloud.tf`
151-
139+
1. Run the helper script `choose_build_type.sh` to enable Bootstrap Terraform Cloud version
152140
```bash
153-
mv ./terraform_cloud.tf.example ./terraform_cloud.tf
141+
./scripts/choose_build_type.sh terraform_cloud
154142
```
155143

156144
1. Rename file `terraform.example.tfvars` to `terraform.tfvars`
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ resource "random_string" "suffix" {
6868

6969
module "gcp_projects_state_bucket" {
7070
source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket"
71-
version = "~> 9.0"
71+
version = "~> 12.0"
7272

7373
name = "${var.bucket_prefix}-${module.seed_bootstrap.seed_project_id}-gcp-projects-tfstate"
7474
project_id = module.seed_bootstrap.seed_project_id
@@ -186,7 +186,7 @@ module "tf_cloud_builder" {
186186

187187
module "bootstrap_csr_repo" {
188188
source = "terraform-google-modules/gcloud/google"
189-
version = "~> 3.1"
189+
version = "~> 4.0"
190190
upgrade = false
191191

192192
create_cmd_entrypoint = "${path.module}/scripts/push-to-repo.sh"
@@ -204,7 +204,7 @@ resource "time_sleep" "cloud_builder" {
204204

205205
module "build_terraform_image" {
206206
source = "terraform-google-modules/gcloud/google"
207-
version = "~> 3.1"
207+
version = "~> 4.0"
208208
upgrade = false
209209

210210
create_cmd_triggers = {
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ resource "google_service_account_iam_member" "self_impersonate" {
120120

121121
module "gcp_projects_state_bucket" {
122122
source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket"
123-
version = "~> 9.0"
123+
version = "~> 12.0"
124124

125125
name = "${var.bucket_prefix}-${module.seed_bootstrap.seed_project_id}-gcp-projects-tfstate"
126126
project_id = module.seed_bootstrap.seed_project_id
@@ -133,4 +133,3 @@ module "gcp_projects_state_bucket" {
133133

134134
depends_on = [module.seed_bootstrap.gcs_bucket_tfstate]
135135
}
136-
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ module "gitlab_cicd" {
108108
module "gitlab_oidc" {
109109
source = "./modules/gitlab-oidc"
110110

111-
project_id = module.gitlab_cicd.project_id
112-
pool_id = "foundation-pool"
113-
provider_id = "foundation-gl-provider"
114-
sa_mapping = local.sa_mapping
115-
attribute_condition = "assertion.user_login=='${var.gl_repos.owner}'"
111+
project_id = module.gitlab_cicd.project_id
112+
pool_id = "foundation-pool"
113+
provider_id = "foundation-gl-provider"
114+
sa_mapping = local.sa_mapping
115+
attribute_condition = "assertion.project_path.startsWith('${var.gl_repos.owner}/')"
116116
}
117117

118118
resource "gitlab_project_variable" "variables" {
@@ -178,7 +178,7 @@ resource "google_service_account_iam_member" "self_impersonate" {
178178

179179
module "gcp_projects_state_bucket" {
180180
source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket"
181-
version = "~> 9.0"
181+
version = "~> 12.0"
182182

183183
name = "${var.bucket_prefix}-${module.seed_bootstrap.seed_project_id}-gcp-projects-tfstate"
184184
project_id = module.seed_bootstrap.seed_project_id
@@ -191,4 +191,3 @@ module "gcp_projects_state_bucket" {
191191

192192
depends_on = [module.seed_bootstrap.gcs_bucket_tfstate]
193193
}
194-

0-bootstrap/terraform_cloud.tf.example renamed to 0-bootstrap/build_terraform_cloud.tf.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ module "tfc_agent_gke" {
304304
service_account_email = google_service_account.terraform-env-sa["bootstrap"].email
305305
service_account_id = google_service_account.terraform-env-sa["bootstrap"].id
306306

307-
//If you are using Terraform Cloud Agents, un-comment this block after the first apply according README instructions
307+
//If you are using Terraform Cloud Agents, un-comment this block after the first apply according to README instructions
308308
# providers = {
309309
# kubernetes = kubernetes
310310
# }

0-bootstrap/groups.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ data "google_organization" "org" {
3434

3535
module "required_group" {
3636
source = "terraform-google-modules/group/google"
37-
version = "~> 0.7"
37+
version = "~> 0.8"
3838
for_each = local.required_groups_to_create
3939

4040
id = each.value
@@ -46,7 +46,7 @@ module "required_group" {
4646

4747
module "optional_group" {
4848
source = "terraform-google-modules/group/google"
49-
version = "~> 0.7"
49+
version = "~> 0.8"
5050
for_each = local.optional_groups_to_create
5151

5252
id = each.value

0 commit comments

Comments
 (0)