Skip to content

Commit f9cd2e1

Browse files
maxi-citbharathkkb
andauthored
chore: improve local deploy instructions (#901)
* first draft updated docs * Apply suggestions from code review Co-authored-by: Bharath KKB <[email protected]>
1 parent 4581750 commit f9cd2e1

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

0-bootstrap/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,14 @@ your current Jenkins manager (controller) environment.
125125

126126
## Deploying with Cloud Build
127127

128-
1. Go to the `0-bootstrap` folder.
128+
1. Clone [terraform-example-foundation](https://github.com/terraform-google-modules/terraform-example-foundation) into your local environment and navigate to the `0-bootstrap` folder.
129+
130+
```bash
131+
git clone https://github.com/terraform-google-modules/terraform-example-foundation.git
132+
133+
cd terraform-example-foundation/0-bootstrap
134+
```
135+
129136
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment:
130137

131138
```bash

1-org/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
109109

110110
### Deploying with Cloud Build
111111

112-
1. Clone the `gcp-org` repo based on the Terraform output from the previous step.
113-
Clone the repo at the same level of the `terraform-example-foundation` folder, the next instructions assume that layout.
114-
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to see the project again.
112+
1. Clone the `gcp-org` repo based on the Terraform output from the `0-bootstrap` step.
113+
Clone the repo at the same level of the `terraform-example-foundation` folder, the following instructions assume this layout.
114+
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.
115115

116116
```bash
117117
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
@@ -120,8 +120,9 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to see
120120
gcloud source repos clone gcp-org --project=${CLOUD_BUILD_PROJECT_ID}
121121
```
122122

123-
- The message `warning: You appear to have cloned an empty repository.` is
123+
**Note:** The message `warning: You appear to have cloned an empty repository.` is
124124
normal and can be ignored.
125+
125126
1. Navigate into the repo, change to a non-production branch and copy contents of foundation to new repo.
126127
All subsequent steps assume you are running them from the `gcp-org` directory.
127128
If you run them from another directory, adjust your copy paths accordingly.
@@ -207,10 +208,11 @@ See `0-bootstrap` [README-Jenkins.md](../0-bootstrap/README-Jenkins.md#deploying
207208

208209
### Running Terraform locally
209210

210-
1. Change into `1-org` folder, copy the Terraform wrapper script and ensure it can be executed.
211+
1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder.
212+
Change into `1-org` folder, copy the Terraform wrapper script and ensure it can be executed.
211213

212214
```bash
213-
cd 1-org
215+
cd terraform-example-foundation/1-org
214216
cp ../build/tf-wrapper.sh .
215217
chmod 755 ./tf-wrapper.sh
216218
```

2-environments/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
7575

7676
### Deploying with Cloud Build
7777

78-
1. Clone repo.
78+
1. Clone the `gcp-environments` repo based on the Terraform output from the `0-bootstrap` step.
79+
Clone the repo at the same level of the `terraform-example-foundation` folder, the following instructions assume this layout.
80+
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.
7981

8082
```bash
8183
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
@@ -162,10 +164,10 @@ See `0-bootstrap` [README-Jenkins.md](../0-bootstrap/README-Jenkins.md#deploying
162164

163165
### Run Terraform locally
164166

165-
1. Change into `2-environments` folder, copy the Terraform wrapper script and ensure it can be executed.
167+
1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder. Change into `2-environments` folder, copy the Terraform wrapper script and ensure it can be executed.
166168

167169
```bash
168-
cd 2-environments
170+
cd terraform-example-foundation/2-environments
169171
cp ../build/tf-wrapper.sh .
170172
chmod 755 ./tf-wrapper.sh
171173
```

3-networks-dual-svpc/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ If you are not able to use Dedicated or Partner Interconnect, you can also use a
134134

135135
### Deploying with Cloud Build
136136

137-
1. Clone repo.
137+
1. Clone the `gcp-networks` repo based on the Terraform output from the `0-bootstrap` step.
138+
Clone the repo at the same level of the `terraform-example-foundation` folder, the following instructions assume this layout.
139+
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.
138140

139141
```bash
140142
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
@@ -267,10 +269,10 @@ See `0-bootstrap` [README-Jenkins.md](../0-bootstrap/README-Jenkins.md#deploying
267269

268270
### Run Terraform locally
269271

270-
1. Change into `3-networks-dual-svpc` folder, copy the Terraform wrapper script and ensure it can be executed.
272+
1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder. Change into `3-networks-dual-svpc` folder, copy the Terraform wrapper script and ensure it can be executed.
271273

272274
```bash
273-
cd 3-networks-dual-svpc
275+
cd terraform-example-foundation/3-networks-dual-svpc
274276
cp ../build/tf-wrapper.sh .
275277
chmod 755 ./tf-wrapper.sh
276278
```

3-networks-hub-and-spoke/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ If you are not able to use Dedicated or Partner Interconnect, you can also use a
143143

144144
### Deploying with Cloud Build
145145

146-
1. Clone repo.
146+
1. Clone the `gcp-networks` repo based on the Terraform output from the `0-bootstrap` step.
147+
Clone the repo at the same level of the `terraform-example-foundation` folder, the following instructions assume this layout.
148+
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.
147149

148150
```bash
149151
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
@@ -276,10 +278,10 @@ See `0-bootstrap` [README-Jenkins.md](../0-bootstrap/README-Jenkins.md#deploying
276278

277279
### Run Terraform locally
278280

279-
1. Change into `3-networks-hub-and-spoke` folder, copy the Terraform wrapper script and ensure it can be executed.
281+
1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder. Change into `3-networks-hub-and-spoke` folder, copy the Terraform wrapper script and ensure it can be executed.
280282

281283
```bash
282-
cd 3-networks-hub-and-spoke
284+
cd terraform-example-foundation/3-networks-hub-and-spoke
283285
cp ../build/tf-wrapper.sh .
284286
chmod 755 ./tf-wrapper.sh
285287
```

4-projects/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
8787

8888
### Deploying with Cloud Build
8989

90-
1. Clone repo.
90+
1. Clone the `gcp-projects` repo based on the Terraform output from the `0-bootstrap` step.
91+
Clone the repo at the same level of the `terraform-example-foundation` folder, the following instructions assume this layout.
92+
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.
9193

9294
```bash
9395
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
@@ -216,10 +218,10 @@ See `0-bootstrap` [README-Jenkins.md](../0-bootstrap/README-Jenkins.md#deploying
216218

217219
### Run Terraform locally
218220

219-
1. Change into `4-projects` folder, copy the Terraform wrapper script and ensure it can be executed.
221+
1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder. Change into `4-projects` folder, copy the Terraform wrapper script and ensure it can be executed.
220222

221223
```bash
222-
cd 4-projects
224+
cd terraform-example-foundation/4-projects
223225
cp ../build/tf-wrapper.sh .
224226
chmod 755 ./tf-wrapper.sh
225227
```
@@ -250,7 +252,7 @@ When using Cloud Build or Jenkins as your CI/CD tool each environment correspond
250252

251253
To use the `validate` option of the `tf-wrapper.sh` script, please follow the [instructions](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install) to install the terraform-tools component.
252254

253-
1. Use `terraform output` to get the Cloud Build project ID and the environment step Terraform Service Account from 0-bootstrap output. An environment variable `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT` will be set using the Terraform Service Account to enable impersonation.
255+
1. Use `terraform output` to get the Cloud Build Project ID and the environment step Terraform Service Account from 0-bootstrap output. An environment variable `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT` will be set using the Terraform Service Account to enable impersonation.
254256

255257
```bash
256258
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="../0-bootstrap/" output -raw cloudbuild_project_id)

5-app-infra/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
8080

8181
### Deploying with Cloud Build
8282

83-
1. Clone the policies repo. **Note:** This repo has the same name as the repo created in step 1-org, to prevent a collision the command below will clone it in folder gcp-policies-app-infra.
83+
1. Clone the `gcp-policies` repo based on the Terraform output from the `0-bootstrap` step.
84+
Clone the repo at the same level of the `terraform-example-foundation` folder, the following instructions assume this layout.
85+
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.
8486

8587
```bash
8688
export INFRA_PIPELINE_PROJECT_ID=$(terraform -chdir="gcp-projects/business_unit_1/shared/" output -raw cloudbuild_project_id)
@@ -89,6 +91,8 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
8991
gcloud source repos clone gcp-policies gcp-policies-app-infra --project=${INFRA_PIPELINE_PROJECT_ID}
9092
```
9193

94+
**Note:** `gcp-policies` repo has the same name as the repo created in step `1-org`. In order to prevent a collision, the previous command will clone this repo in the folder `gcp-policies-app-infra`.
95+
9296
1. Navigate into the repo and copy contents of policy-library to new repo. All subsequent steps assume you are running them
9397
from the gcp-policies-app-infra directory. If you run them from another directory,
9498
adjust your copy paths accordingly.
@@ -190,10 +194,10 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
190194

191195
### Run Terraform locally
192196

193-
1. Change into `5-app-infra` folder, copy the Terraform wrapper script and ensure it can be executed.
197+
1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder. Change into `5-app-infra` folder, copy the Terraform wrapper script and ensure it can be executed.
194198

195199
```bash
196-
cd 5-app-infra
200+
cd terraform-example-foundation/5-app-infra
197201
cp ../build/tf-wrapper.sh .
198202
chmod 755 ./tf-wrapper.sh
199203
```

0 commit comments

Comments
 (0)