@@ -6,10 +6,10 @@ corresponding terraform configurations:
6
6
7
7
| GCP Resource | Terraform Resource | Link to TerraHub Config |
8
8
| -----------------------| --------------------| -------------------------|
9
- | Cloud Function | google_cloudfunctions_function | https://github.com/TerraHubCorp/demo-terraform-automation-gcp/blob/master/google_function/.terrahub.yml#L24 |
10
- | Cloud Storage | google_storage_bucket | https://github.com/TerraHubCorp/demo-terraform-automation-gcp/blob/master/google_storage/.terrahub.yml#L7 |
11
- | Static Website | google_storage_bucket_object | https://github.com/TerraHubCorp/demo-terraform-automation-gcp/blob/master/google_function /.terrahub.yml#L19 |
12
- | IAM Policy | iam_member_object_viewer | https://github.com/TerraHubCorp/demo-terraform-automation-gcp/blob/master/google_storage /.terrahub.yml#L7 |
9
+ | Cloud Function | google_cloudfunctions_function | [ google_function/.terrahub.yml#L24 ] ( https://github.com/TerraHubCorp/demo-terraform-automation-gcp/blob/master/google_function/.terrahub.yml#L24 ) |
10
+ | Cloud Storage | google_storage_bucket | [ google_storage/.terrahub.yml#L7 ] ( https://github.com/TerraHubCorp/demo-terraform-automation-gcp/blob/master/google_storage/.terrahub.yml#L7 ) |
11
+ | Static Website | google_storage_bucket_object | [ static_website/.terrahub.yml#L8 ] ( https://github.com/TerraHubCorp/demo-terraform-automation-gcp/blob/master/static_website /.terrahub.yml#L8 ) |
12
+ | IAM Policy | google_storage_bucket_iam_member | [ iam_object_viewer/.terrahub.yml#L9 ] ( https://github.com/TerraHubCorp/demo-terraform-automation-gcp/blob/master/iam_object_viewer /.terrahub.yml#L9 ) |
13
13
14
14
Follow below instructions to try this out in your own Google Cloud account.
15
15
@@ -193,7 +193,7 @@ Your output should be similar to the one below:
193
193
The source code of Google Function is stored in ` index.js ` :
194
194
195
195
``` shell
196
- cat ' exports.helloGET = (req, res) => { res.send("Hello World!\n"); };' > index.js
196
+ echo ' exports.helloGET = (req, res) => { res.send("Hello World!\n"); };' > index.js
197
197
```
198
198
199
199
The source code of Static Website is cloned from another public repository:
@@ -212,8 +212,8 @@ Run the following command in terminal:
212
212
``` shell
213
213
terrahub component -t google_storage_bucket -n google_storage \
214
214
&& terrahub component -t google_cloudfunctions_function -n google_function -o ../google_storage \
215
- && terrahub component -t google_storage_bucket -n google_static_website -d ./www/.terrahub \
216
- && terrahub component -t google_storage_bucket_iam_member -n iam_member_object_viewer -d ./www/.terrahub - o ../google_static_website
215
+ && terrahub component -t google_storage_bucket -n static_website \
216
+ && terrahub component -t google_storage_bucket_iam_member -n iam_object_viewer - o ../static_website
217
217
```
218
218
219
219
Your output should be similar to the one below:
@@ -295,34 +295,34 @@ Your output should be similar to the one below:
295
295
296
296
Run the following commands in terminal:
297
297
``` shell
298
- terrahub configure -i google_static_website -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/google_static_website /terraform.tfstate'
299
- terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website .name=" ${STORAGE_BUCKET} _website"
300
- terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website .location=' US'
301
- terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website .force_destroy=' true'
302
- terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website .project=' ${local.google_project_id}'
303
- terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website .website.main_page_suffix=' index.html'
304
- terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website .website.not_found_page=' /404.html'
305
- terrahub configure -i google_static_website -c component.template.variable -D -y
306
- terrahub configure -i google_static_website -c build.env.variables.THUB_ENV=' dev'
307
- terrahub configure -i google_static_website -c build.env.variables.THUB_INDEX_FILE=' www.txt'
308
- terrahub configure -i google_static_website -c build.env.variables.THUB_S3_PATH =" gs://${STORAGE_BUCKET} _website"
309
- terrahub configure -i google_static_website -c build.env.variables.THUB_ROBOTS=' ../.. /robots.dev.txt'
310
- terrahub configure -i google_static_website -c build.env.variables.THUB_BUILD_PATH=' ../.. /build'
311
- terrahub configure -i google_static_website -c build.env.variables.THUB_SOURCE_PATH=' ../.. /assets ../.. /static/fonts ../.. /static/img ../.. /views'
312
- terrahub configure -i google_static_website -c build.env.variables.THUB_BUILD_OK=' false'
313
- terrahub configure -i google_static_website -c build.env.variables.THUB_MAX_AGE=' 600'
314
- terrahub configure -i google_static_website -c build.phases.pre_build.commands[0]=' echo "BUILD: Running pre_build step"'
315
- terrahub configure -i google_static_website -c build.phases.pre_build.commands[1]=' ./scripts/download.sh $THUB_INDEX_FILE $THUB_S3_PATH /$THUB_INDEX_FILE'
316
- terrahub configure -i google_static_website -c build.phases.pre_build.commands[2]=' ./scripts/compare.sh $THUB_INDEX_FILE $THUB_SOURCE_PATH'
317
- terrahub configure -i google_static_website -c build.phases.pre_build.finally[0]=' echo "BUILD: pre_build step successful"'
318
- terrahub configure -i google_static_website -c build.phases.build.commands[0]=' echo "BUILD: Running build step"'
319
- terrahub configure -i google_static_website -c build.phases.build.commands[1]=' ../.. /bin/compile.sh'
320
- terrahub configure -i google_static_website -c build.phases.build.finally[0]=' echo "BUILD: build step successful"'
321
- terrahub configure -i google_static_website -c build.phases.post_build.commands[0]=' echo "BUILD: Running post_build step"'
322
- terrahub configure -i google_static_website -c build.phases.post_build.commands[1]=' ./scripts/shasum.sh $THUB_BUILD_PATH/$THUB_INDEX_FILE'
323
- terrahub configure -i google_static_website -c build.phases.post_build.commands[2]=' ./scripts/upload.sh $THUB_BUILD_PATH $THUB_S3_PATH --cache-control max-age=$THUB_MAX_AGE'
324
- terrahub configure -i google_static_website -c build.phases.post_build.commands[3]=' rm -f .terrahub_build.env $THUB_INDEX_FILE'
325
- terrahub configure -i google_static_website -c build.phases.post_build.finally[0]=' echo "BUILD: post_build step successful"'
298
+ terrahub configure -i static_website -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/static_website /terraform.tfstate'
299
+ terrahub configure -i static_website -c component.template.resource.google_storage_bucket.static_website .name=" ${STORAGE_BUCKET} _website"
300
+ terrahub configure -i static_website -c component.template.resource.google_storage_bucket.static_website .location=' US'
301
+ terrahub configure -i static_website -c component.template.resource.google_storage_bucket.static_website .force_destroy=' true'
302
+ terrahub configure -i static_website -c component.template.resource.google_storage_bucket.static_website .project=' ${local.google_project_id}'
303
+ terrahub configure -i static_website -c component.template.resource.google_storage_bucket.static_website .website.main_page_suffix=' index.html'
304
+ terrahub configure -i static_website -c component.template.resource.google_storage_bucket.static_website .website.not_found_page=' /404.html'
305
+ terrahub configure -i static_website -c component.template.variable -D -y
306
+ terrahub configure -i static_website -c build.env.variables.THUB_ENV=' dev'
307
+ terrahub configure -i static_website -c build.env.variables.THUB_INDEX_FILE=' www.txt'
308
+ terrahub configure -i static_website -c build.env.variables.THUB_GS_PATH =" gs://${STORAGE_BUCKET} _website"
309
+ terrahub configure -i static_website -c build.env.variables.THUB_ROBOTS=' ../www /robots.dev.txt'
310
+ terrahub configure -i static_website -c build.env.variables.THUB_BUILD_PATH=' ../www /build'
311
+ terrahub configure -i static_website -c build.env.variables.THUB_SOURCE_PATH=' ../www /assets ../www /static/fonts ../www /static/img ../www /views'
312
+ terrahub configure -i static_website -c build.env.variables.THUB_BUILD_OK=' false'
313
+ terrahub configure -i static_website -c build.env.variables.THUB_MAX_AGE=' 600'
314
+ terrahub configure -i static_website -c build.phases.pre_build.commands[0]=' echo "BUILD: Running pre_build step"'
315
+ terrahub configure -i static_website -c build.phases.pre_build.commands[1]=' ./scripts/download.sh $THUB_INDEX_FILE $THUB_GS_PATH /$THUB_INDEX_FILE'
316
+ terrahub configure -i static_website -c build.phases.pre_build.commands[2]=' ./scripts/compare.sh $THUB_INDEX_FILE $THUB_SOURCE_PATH'
317
+ terrahub configure -i static_website -c build.phases.pre_build.finally[0]=' echo "BUILD: pre_build step successful"'
318
+ terrahub configure -i static_website -c build.phases.build.commands[0]=' echo "BUILD: Running build step"'
319
+ terrahub configure -i static_website -c build.phases.build.commands[1]=' ../www /bin/compile.sh'
320
+ terrahub configure -i static_website -c build.phases.build.finally[0]=' echo "BUILD: build step successful"'
321
+ terrahub configure -i static_website -c build.phases.post_build.commands[0]=' echo "BUILD: Running post_build step"'
322
+ terrahub configure -i static_website -c build.phases.post_build.commands[1]=' ./scripts/shasum.sh $THUB_BUILD_PATH/$THUB_INDEX_FILE'
323
+ terrahub configure -i static_website -c build.phases.post_build.commands[2]=' ./scripts/upload.sh $THUB_BUILD_PATH $THUB_GS_PATH --cache-control max-age=$THUB_MAX_AGE'
324
+ terrahub configure -i static_website -c build.phases.post_build.commands[3]=' rm -f .terrahub_build.env $THUB_INDEX_FILE'
325
+ terrahub configure -i static_website -c build.phases.post_build.finally[0]=' echo "BUILD: post_build step successful"'
326
326
```
327
327
328
328
Your output should be similar to the one below:
@@ -334,13 +334,13 @@ Your output should be similar to the one below:
334
334
335
335
Run the following commands in terminal:
336
336
``` shell
337
- terrahub configure -i iam_member_object_viewer -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/iam_member_object_viewer /terraform.tfstate'
338
- terrahub configure -i iam_member_object_viewer -c component.template.data.terraform_remote_state.storage.backend=' local'
339
- terrahub configure -i iam_member_object_viewer -c component.template.data.terraform_remote_state.storage.config.path=' /tmp/.terrahub/local_backend/google_static_website /terraform.tfstate'
340
- terrahub configure -i iam_member_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_member_object_viewer .bucket=" ${STORAGE_BUCKET} _website"
341
- terrahub configure -i iam_member_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_member_object_viewer .role=" roles/storage.objectViewer"
342
- terrahub configure -i iam_member_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_member_object_viewer .member=" allUsers"
343
- terrahub configure -i iam_member_object_viewer -c component.template.variable -D -y
337
+ terrahub configure -i iam_object_viewer -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/iam_object_viewer /terraform.tfstate'
338
+ terrahub configure -i iam_object_viewer -c component.template.data.terraform_remote_state.storage.backend=' local'
339
+ terrahub configure -i iam_object_viewer -c component.template.data.terraform_remote_state.storage.config.path=' /tmp/.terrahub/local_backend/static_website /terraform.tfstate'
340
+ terrahub configure -i iam_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_object_viewer .bucket=" ${STORAGE_BUCKET} _website"
341
+ terrahub configure -i iam_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_object_viewer .role=" roles/storage.objectViewer"
342
+ terrahub configure -i iam_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_object_viewer .member=" allUsers"
343
+ terrahub configure -i iam_object_viewer -c component.template.variable -D -y
344
344
```
345
345
346
346
Your output should be similar to the one below:
@@ -360,8 +360,8 @@ Your output should be similar to the one below:
360
360
Project: demo-terraform-automation-gcp
361
361
├─ google_storage [path: ./google_storage]
362
362
│ └─ google_function [path: ./google_function]
363
- └─ google_static_website [path: ./www/.terrahub/google_static_website ]
364
- └─ iam_member_object_viewer [path: ./www/.terrahub/iam_member_object_viewer ]
363
+ └─ static_website [path: ./static_website ]
364
+ └─ iam_object_viewer [path: ./iam_object_viewer ]
365
365
```
366
366
367
367
## Run TerraHub Automation
@@ -370,7 +370,7 @@ Project: demo-terraform-automation-gcp
370
370
371
371
Run the following command in terminal:
372
372
``` shell
373
- terrahub run -y -a -i google_storage,google_static_website
373
+ terrahub run -y -a -i google_storage,static_website
374
374
```
375
375
376
376
Your output should be similar to the one below:
@@ -382,13 +382,17 @@ Your output should be similar to the one below:
382
382
Run the following command in terminal:
383
383
384
384
``` shell
385
- terrahub build -i google_function,google_static_website
385
+ terrahub build -i google_function,static_website
386
386
```
387
387
388
388
Your output should be similar to the one below:
389
389
```
390
390
```
391
391
392
+ > NOTE: If you get an error saying `ServiceException: 401 Anonymous caller
393
+ does not have storage.objects.get access to [ *** ] ` , run ` gsutil config` and
394
+ setup default project id.
395
+
392
396
### Run TerraHub Automation
393
397
394
398
Run the following command in terminal:
0 commit comments