You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -64,13 +64,15 @@ This repository is intended as an example to be forked, tweaked, and maintained
64
64
Though this blueprint can help accelerate your foundation design and build, we assume that you have the engineering skills and teams to deploy and customize your own foundation based on your own requirements.
65
65
66
66
We will support:
67
-
- Code is semantically valid, pinned to known good versions, and passes terraform validate and lint checks
68
-
- All PR to this repo must pass integration tests to deploy all resources into a test environment before being merged
69
-
- Feature requests about ease of use of the code, or feature requests that generally apply to all users, are welcome
67
+
68
+
- Code is semantically valid, pinned to known good versions, and passes terraform validate and lint checks
69
+
- All PR to this repo must pass integration tests to deploy all resources into a test environment before being merged
70
+
- Feature requests about ease of use of the code, or feature requests that generally apply to all users, are welcome
70
71
71
72
We will not support:
72
-
- In-place upgrades from a foundation deployed with an earlier version to a more recent version, even for minor version changes, might not be feasible. Repository maintainers do not have visibility to what resources a user deploys on top of their foundation or how the foundation was customized in deployment, so we make no guarantee about avoiding breaking changes.
73
-
- Feature requests that are specific to a single user's requirement and not representative of general best practices
73
+
74
+
- In-place upgrades from a foundation deployed with an earlier version to a more recent version, even for minor version changes, might not be feasible. Repository maintainers do not have visibility to what resources a user deploys on top of their foundation or how the foundation was customized in deployment, so we make no guarantee about avoiding breaking changes.
75
+
- Feature requests that are specific to a single user's requirement and not representative of general best practices
74
76
75
77
## Prerequisites
76
78
@@ -86,21 +88,25 @@ To run the commands described in this document, install the following:
86
88
Version 1.5.7 is the last version before the license model change. To use a later version of Terraform, ensure that the Terraform version used in the Operational System to manually execute part of the steps in `3-networks` and `4-projects` is the same version configured in the following code
87
89
88
90
- 0-bootstrap/modules/jenkins-agent/variables.tf
91
+
89
92
```
90
93
default = "1.5.7"
91
94
```
92
95
93
96
- 0-bootstrap/cb.tf
97
+
94
98
```
95
99
terraform_version = "1.5.7"
96
100
```
97
101
98
102
- scripts/validate-requirements.sh
103
+
99
104
```
100
105
TF_VERSION="1.5.7"
101
106
```
102
107
103
108
- build/github-tf-apply.yaml
109
+
104
110
```
105
111
terraform_version: '1.5.7'
106
112
```
@@ -112,6 +118,7 @@ Version 1.5.7 is the last version before the license model change. To use a late
112
118
```
113
119
114
120
- 0-bootstrap/Dockerfile
121
+
115
122
```
116
123
ARG TERRAFORM_VERSION=1.5.7
117
124
```
@@ -136,7 +143,9 @@ Set the variables in **terraform.tfvars** (`groups` block) to use the specific g
@@ -342,11 +351,164 @@ The following steps introduce the steps to deploy with Cloud Build Alternatively
342
351
343
352
## Running Terraform locally
344
353
345
-
If you deploy using Cloud Build, the bucket information is replaced in the state
346
-
backends as part of the build process when the build is executed by Cloud Build.
347
-
If you want to execute Terraform locally, you need to add your Cloud
348
-
Storage bucket to the `backend.tf` files.
349
-
Each step has instructions for this change.
354
+
The following steps will guide you through deploying without using Cloud Build.
355
+
356
+
1. Clone [terraform-example-foundation](https://github.com/terraform-google-modules/terraform-example-foundation) into your local environment and create to the `gcp-bootstrap` folder at the same level. Copy the `0-bootstrap` content and `.gitignore` to `gcp-bootstrap`.
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment:
381
+
382
+
```bash
383
+
mv terraform.example.tfvars terraform.tfvars
384
+
```
385
+
386
+
1. Rename `cb.tf` to `cb.tf.example`:
387
+
388
+
```bash
389
+
mv cb.tf cb.tf.example
390
+
```
391
+
392
+
1. Comment Cloud Build related outputs at `outputs.tf`.
393
+
394
+
1. In `sa.tf` file, comment out lines related to Cloud Build. Specifically, search for`cicd_project_iam_member` and comment out the corresponding module, as well as the "depends_on" meta-argumentin any modules that depend on the commented module.
395
+
396
+
1. In `sa.tf` file, search for`local.cicd_project_id` and comment out the corresponding code.
397
+
398
+
1. Use the helper script [validate-requirements.sh](../scripts/validate-requirements.sh) to validate your environment:
**Note:** The script is not able to validate if the user is in a Cloud Identity or Google Workspace group with the required roles.
405
+
406
+
1. Run `terraform init` and `terraform plan` and review the output.
407
+
408
+
```bash
409
+
git checkout plan
410
+
terraform init
411
+
terraform plan -input=false -out bootstrap.tfplan
412
+
```
413
+
414
+
1. Create a new folder called gcp-policies at the same directory level as the `terraform-example-foundation` folder. Initialize a Git repository, create a branch called `main`, and copy the contents of the `policy-library` directory from the `terraform-example-foundation` folder into the gcp-policies folder.
1. Commit changes to the main branch of the policy repo. This way you can manage versions locally.
428
+
429
+
```bash
430
+
git add .
431
+
git commit -m 'Initialize policy library repo'
432
+
```
433
+
434
+
1. Navigate back to `gcp-bootstrap` repo.
435
+
436
+
```bash
437
+
cd ../gcp-bootstrap
438
+
```
439
+
440
+
1. To validate your policies, run `gcloud beta terraform vet`. For installation instructions, see [Install Google Cloud CLI](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install).
441
+
442
+
1. Run the following commands and check for violations:
443
+
444
+
```bash
445
+
export VET_PROJECT_ID=A-VALID-PROJECT-ID
446
+
terraform show -json bootstrap.tfplan > bootstrap.json
447
+
gcloud beta terraform vet bootstrap.json --policy-library="$(pwd)/../gcp-policies" --project ${VET_PROJECT_ID}
448
+
```
449
+
450
+
*`A-VALID-PROJECT-ID`* must be an existing project you have access to. This is necessary because `gcloud beta terraform vet` needs to link resources to a valid Google Cloud Platform project.
451
+
452
+
1. Commit validated code in plan branch.
453
+
454
+
```bash
455
+
git add .
456
+
git commit -m "Initial version os gcp-bootstrap."
457
+
```
458
+
459
+
1. Checkout `shared` branch and merge the `plan` branch into it. Then, Run `terraform apply`.
460
+
461
+
```bash
462
+
git checkout shared
463
+
git merge plan
464
+
465
+
terraform apply bootstrap.tfplan
466
+
```
467
+
468
+
1. Run `terraform output` to get the email address of the terraform service accounts that will be used to run steps manually and the state bucket that will be used by step `4-projects`.
1. Copy the backend and update `backend.tf` with the name of your Google Cloud Storage bucket for Terraform's state. Also update the `backend.tf` of all steps.
0 commit comments