@@ -47,6 +47,7 @@ gcloud services enable cloudresourcemanager.googleapis.com
47
47
gcloud services enable cloudbilling.googleapis.com
48
48
gcloud services enable iam.googleapis.com
49
49
gcloud services enable cloudfunctions.googleapis.com
50
+ gcloud services enable storage-component.googleapis.com
50
51
```
51
52
52
53
Your output should be similar to the one below:
@@ -110,12 +111,20 @@ Your output should be similar to the one below:
110
111
✅ Project successfully initialized
111
112
```
112
113
114
+ > NOTE: For this demo we have added "index.js" file which you have to copy in "demo-terraform-automation-google" dir
115
+
116
+ > NOTE: For this demo we have run the following command in terminal
117
+ git clone https://github.com/TerraHubCorp/www.git \
118
+ && rm -rf ./www/.terrahub*
119
+
113
120
## Create TerraHub Components from Templates
114
121
115
122
Run the following command in terminal:
116
123
``` shell
117
124
terrahub component -t google_storage_bucket -n google_storage \
118
- && terrahub component -t google_cloudfunctions_function -n google_function -o ../google_storage
125
+ && terrahub component -t google_cloudfunctions_function -n google_function -o ../google_storage \
126
+ && terrahub component -t google_storage_bucket -n google_static_website -d ./www/.terrahub \
127
+ && terrahub component -t google_storage_bucket_iam_member -n iam_member_object_viewer -d ./www/.terrahub -o ../google_static_website
119
128
```
120
129
121
130
Your output should be similar to the one below:
@@ -208,6 +217,63 @@ Your output should be similar to the one below:
208
217
✅ Done
209
218
```
210
219
220
+ ## Customize TerraHub Component for Google Cloud Static WebSite
221
+
222
+ Run the following command in terminal:
223
+ ``` shell
224
+ terrahub configure -i google_static_website -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/google_static_website/terraform.tfstate'
225
+ terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website.name=" ${STORAGE_BUCKET} _website"
226
+ terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website.location=' US'
227
+ terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website.force_destroy=' true'
228
+ terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website.project=' ${local.google_project_id}'
229
+ terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website.website.main_page_suffix=' index.html'
230
+ terrahub configure -i google_static_website -c component.template.resource.google_storage_bucket.google_static_website.website.not_found_page=' /404.html'
231
+ terrahub configure -i google_static_website -c component.template.variable -D -y
232
+ terrahub configure -i google_static_website -c build.env.variables.THUB_ENV=' dev'
233
+ terrahub configure -i google_static_website -c build.env.variables.THUB_INDEX_FILE=' www.txt'
234
+ terrahub configure -i google_static_website -c build.env.variables.THUB_S3_PATH=" gs://${STORAGE_BUCKET} _website"
235
+ terrahub configure -i google_static_website -c build.env.variables.THUB_ROBOTS=' ../../robots.dev.txt'
236
+ terrahub configure -i google_static_website -c build.env.variables.THUB_BUILD_PATH=' ../../build'
237
+ terrahub configure -i google_static_website -c build.env.variables.THUB_SOURCE_PATH=' ../../assets ../../static/fonts ../../static/img ../../views'
238
+ terrahub configure -i google_static_website -c build.env.variables.THUB_BUILD_OK=' false'
239
+ terrahub configure -i google_static_website -c build.env.variables.THUB_MAX_AGE=' 600'
240
+ terrahub configure -i google_static_website -c build.phases.pre_build.commands[0]=' echo "BUILD: Running pre_build step"'
241
+ 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'
242
+ terrahub configure -i google_static_website -c build.phases.pre_build.commands[2]=' ./scripts/compare.sh $THUB_INDEX_FILE $THUB_SOURCE_PATH'
243
+ terrahub configure -i google_static_website -c build.phases.pre_build.finally[0]=' echo "BUILD: pre_build step successful"'
244
+ terrahub configure -i google_static_website -c build.phases.build.commands[0]=' echo "BUILD: Running build step"'
245
+ terrahub configure -i google_static_website -c build.phases.build.commands[1]=' ../../bin/compile.sh'
246
+ terrahub configure -i google_static_website -c build.phases.build.finally[0]=' echo "BUILD: build step successful"'
247
+ terrahub configure -i google_static_website -c build.phases.post_build.commands[0]=' echo "BUILD: Running post_build step"'
248
+ terrahub configure -i google_static_website -c build.phases.post_build.commands[1]=' ./scripts/shasum.sh $THUB_BUILD_PATH/$THUB_INDEX_FILE'
249
+ 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'
250
+ terrahub configure -i google_static_website -c build.phases.post_build.commands[3]=' rm -f .terrahub_build.env $THUB_INDEX_FILE'
251
+ terrahub configure -i google_static_website -c build.phases.post_build.finally[0]=' echo "BUILD: post_build step successful"'
252
+ ```
253
+
254
+ Your output should be similar to the one below:
255
+ ```
256
+ ✅ Done
257
+ ```
258
+
259
+ ## Customize TerraHub Component for IAM Member Object Viewer
260
+
261
+ Run the following command in terminal:
262
+ ``` shell
263
+ terrahub configure -i iam_member_object_viewer -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/iam_member_object_viewer/terraform.tfstate'
264
+ terrahub configure -i iam_member_object_viewer -c component.template.data.terraform_remote_state.storage.backend=' local'
265
+ 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'
266
+ terrahub configure -i iam_member_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_member_object_viewer.bucket=" ${STORAGE_BUCKET} _website"
267
+ terrahub configure -i iam_member_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_member_object_viewer.role=" roles/storage.objectViewer"
268
+ terrahub configure -i iam_member_object_viewer -c component.template.resource.google_storage_bucket_iam_member.iam_member_object_viewer.member=" allUsers"
269
+ terrahub configure -i iam_member_object_viewer -c component.template.variable -D -y
270
+ ```
271
+
272
+ Your output should be similar to the one below:
273
+ ```
274
+ ✅ Done
275
+ ```
276
+
211
277
## Visualize TerraHub Components
212
278
213
279
Run the following command in terminal:
@@ -218,17 +284,19 @@ terrahub graph
218
284
Your output should be similar to the one below:
219
285
```
220
286
Project: demo-terraform-automation-google
221
- └─ google_storage [path: ./google_storage]
222
- └─ google_function [path: ./google_function]
287
+ ├─ google_storage [path: ./google_storage]
288
+ │ └─ google_function [path: ./google_function]
289
+ └─ google_static_website [path: ./www/.terrahub/google_static_website]
290
+ └─ iam_member_object_viewer [path: ./www/.terrahub/iam_member_object_viewer]
223
291
```
224
292
225
293
226
294
## Run TerraHub Automation
227
295
228
296
Run the following command in terminal:
229
297
``` shell
230
- terrahub run -a -y -i google_storage
231
- terrahub build -i google_function
298
+ terrahub run -a -y -i google_storage,google_static_website
299
+ terrahub build -i google_function,google_static_website
232
300
terrahub run -a -y
233
301
```
234
302
@@ -241,4 +309,5 @@ Your output should be similar to the one below:
241
309
Run the following command in terminal:
242
310
```
243
311
curl https://us-central1-terrahub-123456.cloudfunctions.net/demofunctionxxxxxxxx
312
+ curl https://${STORAGE_BUCKET}_website.storage.googleapis.com/index.html
244
313
```
0 commit comments