Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions 0-bootstrap/README-GitHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,9 @@ You must be [authenticated to GitHub](https://docs.github.com/en/authentication/
cd ./envs/shared
```

1. In the versions file `./versions.tf` un-comment the `github` required provider
1. In the variables file `./variables.tf` un-comment variables in the section `Specific to github_bootstrap`
1. In the outputs file `./outputs.tf` Comment-out outputs in the section `Specific to cloudbuild_module`
1. In the outputs file `./outputs.tf` un-comment outputs in the section `Specific to github_bootstrap`
1. Rename file `./cb.tf` to `./cb.tf.example`

```bash
mv ./cb.tf ./cb.tf.example
```

1. Rename file `./github.tf.example` to `./github.tf`

1. Run the helper script `choose_build_type.sh` to enable Bootstrap GitHub version
```bash
mv ./github.tf.example ./github.tf
./scripts/choose_build_type.sh github
```

1. Rename file `terraform.example.tfvars` to `terraform.tfvars`
Expand Down
17 changes: 4 additions & 13 deletions 0-bootstrap/README-GitLab.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ It is a best practice to have two separate projects here (`prj-b-seed` and `prj-
On one hand, `prj-b-seed` stores terraform state and has the Service Accounts able to create / modify infrastructure.
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`.

## Requirements

To run the instructions described in this document, install the following:

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

1. In the versions file `./versions.tf` un-comment the `gitlab` required provider
1. In the variables file `./variables.tf` un-comment variables in the section `Specific to gitlab_bootstrap`
1. In the outputs file `./outputs.tf` Comment-out outputs in the section `Specific to cloudbuild_module`
1. In the outputs file `./outputs.tf` un-comment outputs in the section `Specific to gitlab_bootstrap`
1. Rename file `./cb.tf` to `./cb.tf.example`

```bash
mv ./cb.tf ./cb.tf.example
```

1. Rename file `./gitlab.tf.example` to `./gitlab.tf`

1. Run the helper script `choose_build_type.sh` to enable Bootstrap GitLab version
```bash
mv ./gitlab.tf.example ./gitlab.tf
./scripts/choose_build_type.sh gitlab
```

1. Rename file `terraform.example.tfvars` to `terraform.tfvars`
Expand Down
15 changes: 2 additions & 13 deletions 0-bootstrap/README-Jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,11 @@ You arrived to these instructions because you are using the `jenkins_bootstrap`
cd ./envs/shared
```

1. Activate the Jenkins module and disable the Cloud Build module. This implies manually editing the following files:
1. Rename file `./cb.tf` to `./cb.tf.example`

```bash
mv ./cb.tf ./cb.tf.example
```

1. Rename file `./jenkins.tf.example` to `./jenkins.tf`

1. Run the helper script `choose_build_type.sh` to enable Bootstrap Jenkins version
```bash
mv ./jenkins.tf.example ./jenkins.tf
./scripts/choose_build_type.sh jenkins
```

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

```bash
Expand Down
16 changes: 2 additions & 14 deletions 0-bootstrap/README-Terraform-Cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,9 @@ You must be authenticated to the VCS provider. See [GitHub authentication](https
cd ./envs/shared
```

1. In the versions file `./versions.tf` un-comment the `tfe` required provider
1. In the variables file `./variables.tf` un-comment variables in the section `Specific to tfc_bootstrap`
1. In the outputs file `./outputs.tf` Comment-out outputs in the section `Specific to cloudbuild_module`
1. In the outputs file `./outputs.tf` un-comment outputs in the section `Specific to tfc_bootstrap`
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`
1. Rename file `./cb.tf` to `./cb.tf.example`

```bash
mv ./cb.tf ./cb.tf.example
```

1. Rename file `.terraform_cloud.tf.example` to `./terraform_cloud.tf`

1. Run the helper script `choose_build_type.sh` to enable Bootstrap Terraform Cloud version
```bash
mv ./terraform_cloud.tf.example ./terraform_cloud.tf
./scripts/choose_build_type.sh terraform_cloud
```

1. Rename file `terraform.example.tfvars` to `terraform.tfvars`
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ module "tfc_agent_gke" {
service_account_email = google_service_account.terraform-env-sa["bootstrap"].email
service_account_id = google_service_account.terraform-env-sa["bootstrap"].id

//If you are using Terraform Cloud Agents, un-comment this block after the first apply according README instructions
//If you are using Terraform Cloud Agents, un-comment this block after the first apply according to README instructions
# providers = {
# kubernetes = kubernetes
# }
Expand Down
149 changes: 0 additions & 149 deletions 0-bootstrap/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,152 +80,3 @@ output "optional_groups" {
description = "List of Google Groups created that are optional to the Example Foundation steps."
value = var.groups.create_optional_groups == false ? tomap(var.groups.optional_groups) : tomap({ for key, value in module.optional_group : key => value.id })
}

/* ----------------------------------------
Specific to cloudbuild_module
---------------------------------------- */
# Comment-out the cloudbuild_bootstrap module and its outputs if you want to use
# GitHub Actions, GitLab CI/CD, Terraform Cloud, or Jenkins instead of Cloud Build
output "cloudbuild_project_id" {
description = "Project where Cloud Build configuration and terraform container image will reside."
value = module.tf_source.cloudbuild_project_id
}

output "gcs_bucket_cloudbuild_artifacts" {
description = "Bucket used to store Cloud Build artifacts in cicd project."
value = { for key, value in module.tf_workspace : key => replace(value.artifacts_bucket, local.bucket_self_link_prefix, "") }
}

output "gcs_bucket_cloudbuild_logs" {
description = "Bucket used to store Cloud Build logs in cicd project."
value = { for key, value in module.tf_workspace : key => replace(value.logs_bucket, local.bucket_self_link_prefix, "") }
}

output "cloud_builder_artifact_repo" {
description = "Artifact Registry (AR) Repository created to store TF Cloud Builder images."
value = "projects/${module.tf_source.cloudbuild_project_id}/locations/${var.default_region}/repositories/${module.tf_cloud_builder.artifact_repo}"
}

output "csr_repos" {
description = "List of Cloud Source Repos created by the module, linked to Cloud Build triggers."
value = { for k, v in module.tf_source.csr_repos : k => {
"id" = v.id,
"name" = v.name,
"project" = v.project,
"url" = v.url,
}
}
}

output "cloud_build_private_worker_pool_id" {
description = "ID of the Cloud Build private worker pool."
value = module.tf_private_pool.private_worker_pool_id
}

output "cloud_build_worker_range_id" {
description = "The Cloud Build private worker IP range ID."
value = module.tf_private_pool.worker_range_id
}

output "cloud_build_worker_peered_ip_range" {
description = "The IP range of the peered service network."
value = module.tf_private_pool.worker_peered_ip_range
}

output "cloud_build_peered_network_id" {
description = "The ID of the Cloud Build peered network."
value = module.tf_private_pool.peered_network_id
}

/* ----------------------------------------
Specific to github_bootstrap
---------------------------------------- */
# Un-comment github_bootstrap and its outputs if you want to use GitHub Actions instead of Cloud Build
# output "cicd_project_id" {
# description = "Project where the CI/CD infrastructure for GitHub Action resides."
# value = module.gh_cicd.project_id
# }

/* ----------------------------------------
Specific to jenkins_bootstrap module
---------------------------------------- */
# # Un-comment the jenkins_bootstrap module and its outputs if you want to use Jenkins instead of Cloud Build
# output "cicd_project_id" {
# description = "Project where the [CI/CD Pipeline](/docs/GLOSSARY.md#foundation-cicd-pipeline) (Jenkins Agents and terraform builder container image) reside."
# value = module.jenkins_bootstrap.cicd_project_id
# }

# output "jenkins_agent_gce_instance_id" {
# description = "Jenkins Agent GCE Instance id."
# value = module.jenkins_bootstrap.jenkins_agent_gce_instance_id
# }

# output "jenkins_agent_vpc_id" {
# description = "Jenkins Agent VPC name."
# value = module.jenkins_bootstrap.jenkins_agent_vpc_id
# }

# output "jenkins_agent_sa_email" {
# description = "Email for privileged custom service account for Jenkins Agent GCE instance."
# value = module.jenkins_bootstrap.jenkins_agent_sa_email
# }

# output "jenkins_agent_sa_name" {
# description = "Fully qualified name for privileged custom service account for Jenkins Agent GCE instance."
# value = module.jenkins_bootstrap.jenkins_agent_sa_name
# }

# output "gcs_bucket_jenkins_artifacts" {
# description = "Bucket used to store Jenkins artifacts in Jenkins project."
# value = module.jenkins_bootstrap.gcs_bucket_jenkins_artifacts
# }

/* ----------------------------------------
Specific to gitlab_bootstrap
---------------------------------------- */
# Un-comment gitlab_bootstrap and its outputs if you want to use GitLab CI/CD instead of Cloud Build
# output "cicd_project_id" {
# description = "Project where the CI/CD infrastructure for GitLab CI/CD resides."
# value = module.gitlab_cicd.project_id
# }

/* ----------------------------------------
Specific to tfc_bootstrap
---------------------------------------- */
# Un-comment tfc_bootstrap and its outputs if you want to use Terraform Cloud instead of Cloud Build
# output "cicd_project_id" {
# description = "Project where the CI/CD infrastructure for Terraform Cloud resides."
# value = module.tfc_cicd.project_id
# }
#
# output "tfc_org_name" {
# description = "Name of the TFC organization."
# value = var.tfc_org_name
# }

/* ----------------------------------------
Specific to tfc_bootstrap with Terraform Cloud Agents
---------------------------------------- */
# Un-comment if you want to use Terraform Cloud Agents
# (In other words, un-comment if you set enable_tfc_cloud_agents to true on .tfvars)

# output "kubernetes_endpoint" {
# description = "The GKE cluster endpoint"
# sensitive = true
# value = module.tfc_agent_gke[0].kubernetes_endpoint
# }

# output "service_account" {
# description = "The default service account used for TFC agent nodes"
# value = module.tfc_agent_gke[0].service_account
# }

# output "cluster_name" {
# description = "GKE cluster name"
# value = module.tfc_agent_gke[0].cluster_name
# }

# output "hub_cluster_membership_id" {
# value = module.tfc_agent_gke[0].hub_cluster_membership_id
# description = "The ID of the cluster membership"
# }
69 changes: 69 additions & 0 deletions 0-bootstrap/outputs_cb.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* ----------------------------------------
Specific to cloudbuild_module
---------------------------------------- */
output "cloudbuild_project_id" {
description = "Project where Cloud Build configuration and terraform container image will reside."
value = module.tf_source.cloudbuild_project_id
}

output "gcs_bucket_cloudbuild_artifacts" {
description = "Bucket used to store Cloud Build artifacts in cicd project."
value = { for key, value in module.tf_workspace : key => replace(value.artifacts_bucket, local.bucket_self_link_prefix, "") }
}

output "gcs_bucket_cloudbuild_logs" {
description = "Bucket used to store Cloud Build logs in cicd project."
value = { for key, value in module.tf_workspace : key => replace(value.logs_bucket, local.bucket_self_link_prefix, "") }
}

output "cloud_builder_artifact_repo" {
description = "Artifact Registry (AR) Repository created to store TF Cloud Builder images."
value = "projects/${module.tf_source.cloudbuild_project_id}/locations/${var.default_region}/repositories/${module.tf_cloud_builder.artifact_repo}"
}

output "csr_repos" {
description = "List of Cloud Source Repos created by the module, linked to Cloud Build triggers."
value = { for k, v in module.tf_source.csr_repos : k => {
"id" = v.id,
"name" = v.name,
"project" = v.project,
"url" = v.url,
}
}
}

output "cloud_build_private_worker_pool_id" {
description = "ID of the Cloud Build private worker pool."
value = module.tf_private_pool.private_worker_pool_id
}

output "cloud_build_worker_range_id" {
description = "The Cloud Build private worker IP range ID."
value = module.tf_private_pool.worker_range_id
}

output "cloud_build_worker_peered_ip_range" {
description = "The IP range of the peered service network."
value = module.tf_private_pool.worker_peered_ip_range
}

output "cloud_build_peered_network_id" {
description = "The ID of the Cloud Build peered network."
value = module.tf_private_pool.peered_network_id
}
23 changes: 23 additions & 0 deletions 0-bootstrap/outputs_github.tf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* ----------------------------------------
Specific to github_bootstrap
---------------------------------------- */
output "cicd_project_id" {
description = "Project where the CI/CD infrastructure for GitHub Action resides."
value = module.gh_cicd.project_id
}
23 changes: 23 additions & 0 deletions 0-bootstrap/outputs_gitlab.tf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* ----------------------------------------
Specific to gitlab_bootstrap
---------------------------------------- */
output "cicd_project_id" {
description = "Project where the CI/CD infrastructure for GitLab CI/CD resides."
value = module.gitlab_cicd.project_id
}
Loading