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