@@ -114,7 +114,8 @@ Your output should be similar to the one below:
114
114
Run the following command in terminal:
115
115
``` shell
116
116
terrahub component -t google_storage_bucket -n demo_storage_bucket \
117
- && terrahub component -t google_cloudfunctions_function -n demo_function -o ../demo_storage_bucket
117
+ && terrahub component -t google_cloudfunctions_function -n demo_function -o ../demo_storage_bucket \
118
+ && terrahub component -t google_storage_bucket -n demo_www -o ../demo_storage_bucket
118
119
```
119
120
120
121
Your output should be similar to the one below:
@@ -142,7 +143,7 @@ Your output should be similar to the one below:
142
143
Run the following command in terminal:
143
144
``` shell
144
145
terrahub configure -i demo_storage_bucket -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/demo_storage_bucket/terraform.tfstate'
145
- terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.name=' demo_storage_bucket_${local.project["code"]} '
146
+ terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.name=' demo_storage_bucket_a123456b '
146
147
terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.location=' US'
147
148
terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.project=' ${local.google_project_id}'
148
149
terrahub configure -i demo_storage_bucket -c component.template.variable -D -y
@@ -161,7 +162,7 @@ terrahub configure -i demo_function -c component.template.terraform.backend.loca
161
162
terrahub configure -i demo_function -c component.template.data.terraform_remote_state.storage.backend=' local'
162
163
terrahub configure -i demo_function -c component.template.data.terraform_remote_state.storage.config.path=' /tmp/.terrahub/local_backend/demo_storage_bucket/terraform.tfstate'
163
164
terrahub configure -i demo_function -c component.template.resource.google_storage_bucket_object.demo_object.name=' demo.zip'
164
- terrahub configure -i demo_function -c component.template.resource.google_storage_bucket_object.demo_object.bucket=' ${data.terraform_remote_state.storage.thub_id}'
165
+ terrahub configure -i demo_function -c component.template.resource.google_storage_bucket_object.demo_object.bucket=' ${data.terraform_remote_state.storage.thub_id}/deploy/demo_function '
165
166
terrahub configure -i demo_function -c component.template.resource.google_storage_bucket_object.demo_object.source=' ./demo.zip'
166
167
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.depends_on[0]=' google_storage_bucket_object.demo_object'
167
168
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.name=' demofunction${local.project["code"]}'
@@ -179,18 +180,25 @@ terrahub configure -i demo_function -c component.template.output -D -y
179
180
terrahub configure -i demo_function -c component.template.output.id.value=' ${google_cloudfunctions_function.demo_function.id}'
180
181
terrahub configure -i demo_function -c component.template.output.trigger_url.value=' ${google_cloudfunctions_function.demo_function.https_trigger_url}'
181
182
terrahub configure -i demo_function -c build.env.variables.THUB_FUNCTION_ZIP=' demo.zip'
182
- terrahub configure -i demo_function -c build.env.variables.THUB_BUILD_PATH=' ..'
183
183
terrahub configure -i demo_function -c build.env.variables.THUB_FUNCTION_TXT=' demo.txt'
184
- terrahub configure -i demo_function -c build.env.variables.THUB_BUILD_OK=' true'
184
+ terrahub configure -i demo_function -c build.env.variables.COMPONENT_NAME=' demo_function'
185
+ terrahub configure -i demo_function -c build.env.variables.OBJECT_NAME=' demo_object'
186
+ terrahub configure -i demo_function -c build.env.variables.THUB_BUILD_PATH=' ..'
187
+ terrahub configure -i demo_function -c build.env.variables.THUB_BUILD_OK=' false'
188
+ terrahub configure -i demo_function -c build.env.variables.THUB_BUCKET_PATH=' gs://demo_storage_bucket_a123456b'
189
+ terrahub configure -i demo_function -c build.env.variables.THUB_BUCKET_KEY: ' deploy/demo_function'
185
190
terrahub configure -i demo_function -c build.phases.pre_build.commands[0]=' echo "BUILD: Running pre_build step"'
186
- terrahub configure -i demo_function -c build.phases.pre_build.commands[1]=' if [ ! -e "$THUB_FUNCTION_TXT" ]; then touch "$THUB_FUNCTION_TXT"; fi'
191
+ terrahub configure -i demo_function -c build.phases.pre_build.commands[1]=' ./scripts/download.sh $THUB_FUNCTION_TXT $THUB_BUCKET_PATH/$THUB_BUCKET_KEY/$THUB_FUNCTION_TXT'
192
+ terrahub configure -i demo_function -c build.phases.pre_build.commands[2]=' ./scripts/compare.sh $THUB_FUNCTION_TXT $THUB_BUILD_PATH/*.js'
187
193
terrahub configure -i demo_function -c build.phases.pre_build.finally[0]=' echo "BUILD: pre_build step successful"'
188
194
terrahub configure -i demo_function -c build.phases.build.commands[0]=' echo "BUILD: Running build step"'
189
- terrahub configure -i demo_function -c build.phases.build.commands[1]=' if [ "$(head -n 1 "$THUB_FUNCTION_TXT")" != "$(stat -c %y "${THUB_BUILD_PATH}/index.js")" ]; then zip -j ${THUB_FUNCTION_ZIP} ${THUB_BUILD_PATH}/index.js; fi'
190
- terrahub configure -i demo_function -c build.phases.build.commands[2]=' if [ "$(head -n 1 "$THUB_FUNCTION_TXT")" != "$(stat -c %y "${THUB_BUILD_PATH}/index.js")" ]; then terrahub configure -i demo_function -c component.template.resource.google_storage_bucket_object.demo_object.name=$(date +%s).zip; fi'
195
+ terrahub configure -i demo_function -c build.phases.build.commands[1]=' ./scripts/build.sh $COMPONENT_NAME $OBJECT_NAME $THUB_BUCKET_KEY/'
191
196
terrahub configure -i demo_function -c build.phases.build.finally[0]=' echo "BUILD: build step successful"'
192
197
terrahub configure -i demo_function -c build.phases.post_build.commands[0]=' echo "BUILD: Running post_build step"'
193
- terrahub configure -i demo_function -c build.phases.post_build.commands[1]=' echo $(stat -c %y "${THUB_BUILD_PATH}/index.js") > "$THUB_FUNCTION_TXT"'
198
+ terrahub configure -i demo_function -c build.phases.post_build.commands[1]=' ./scripts/shasum.sh $THUB_FUNCTION_TXT'
199
+ terrahub configure -i demo_function -c build.phases.post_build.commands[2]=' ./scripts/zip.sh $THUB_FUNCTION_ZIP $THUB_BUILD_PATH/*.js'
200
+ terrahub configure -i demo_function -c build.phases.post_build.commands[3]=' ./scripts/upload.sh $THUB_FUNCTION_TXT $THUB_BUCKET_PATH/$THUB_BUCKET_KEY/$THUB_FUNCTION_TXT'
201
+ terrahub configure -i demo_function -c build.phases.post_build.commands[4]=' rm -f .terrahub_build.env $THUB_FUNCTION_TXT'
194
202
terrahub configure -i demo_function -c build.phases.post_build.finally[0]=' echo "BUILD: post_build step successful"'
195
203
```
196
204
@@ -199,6 +207,19 @@ Your output should be similar to the one below:
199
207
✅ Done
200
208
```
201
209
210
+ ## Customize TerraHub Component for Frontend
211
+
212
+ Run the following command in terminal:
213
+ ``` shell
214
+ terrahub configure -i demo_www -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/demo_www/terraform.tfstate'
215
+
216
+ ```
217
+
218
+ Your output should be similar to the one below:
219
+ ```
220
+ ✅ Done
221
+ ```
222
+
202
223
## Visualize TerraHub Components
203
224
204
225
Run the following command in terminal:
@@ -218,7 +239,8 @@ Project: demo-terraform-automation-google
218
239
219
240
Run the following command in terminal:
220
241
``` shell
221
- terrahub build -i demo_function
242
+ terrahub run -a -y -i demo_storage
243
+ terrahub build -i demo_function,demo_www
222
244
terrahub run -a -y
223
245
```
224
246
0 commit comments