@@ -114,8 +114,7 @@ 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_storage_bucket_object -n demo_object -o ../demo_storage_bucket \
118
- && terrahub component -t google_cloudfunctions_function -n demo_function -o ../demo_object
117
+ && terrahub component -t google_cloudfunctions_function -n demo_function -o ../demo_storage_bucket
119
118
```
120
119
121
120
Your output should be similar to the one below:
@@ -145,7 +144,7 @@ Run the following command in terminal:
145
144
terrahub configure -i demo_storage_bucket -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/demo_storage_bucket/terraform.tfstate'
146
145
terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.name=' demo_storage_bucket_${local.project["code"]}'
147
146
terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.location=' US'
148
- terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.project=" ${GOOGLE_CLOUD_PROJECT} "
147
+ terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.project=' ${local.google_project_id} '
149
148
terrahub configure -i demo_storage_bucket -c component.template.variable -D -y
150
149
```
151
150
@@ -154,56 +153,45 @@ Your output should be similar to the one below:
154
153
✅ Done
155
154
```
156
155
157
- ## Customize TerraHub Component for Storage Bucket Object
158
-
159
- Run the following command in terminal:
160
- ``` shell
161
- terrahub configure -i demo_object -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/demo_object/terraform.tfstate'
162
- terrahub configure -i demo_object -c component.template.data.terraform_remote_state.storage.backend=' local'
163
- terrahub configure -i demo_object -c component.template.data.terraform_remote_state.storage.config.path=' /tmp/.terrahub/local_backend/demo_storage_bucket/terraform.tfstate'
164
- terrahub configure -i demo_object -c component.template.resource.google_storage_bucket_object.demo_object.name=' demo.zip'
165
- terrahub configure -i demo_object -c component.template.resource.google_storage_bucket_object.demo_object.bucket=' ${data.terraform_remote_state.storage.thub_id}'
166
- terrahub configure -i demo_object -c component.template.resource.google_storage_bucket_object.demo_object.source=' ./demo.zip'
167
- terrahub configure -i demo_object -c component.template.variable -D -y
168
- terrahub configure -i demo_object -c build.env.variables.THUB_LAMBDA_ZIP=' demo.zip'
169
- terrahub configure -i demo_object -c build.env.variables.THUB_BUILD_PATH=' ..'
170
- terrahub configure -i demo_object -c build.env.variables.THUB_BUILD_OK=' true'
171
- terrahub configure -i demo_object -c build.phases.build.commands[0]=' echo "BUILD: Running build step"'
172
- terrahub configure -i demo_object -c build.phases.build.commands[1]=' zip -j ${THUB_LAMBDA_ZIP} ${THUB_BUILD_PATH}/index.js'
173
- terrahub configure -i demo_object -c build.phases.build.finally[0]=' echo "BUILD: build step successful"'
174
- terrahub configure -i demo_object -c build.phases.post_build.commands[0]=' echo "BUILD: Running post_build step"'
175
- terrahub configure -i demo_object -c build.phases.post_build.commands[1]=' rm -rf ./nodejs-docs-samples'
176
- terrahub configure -i demo_object -c build.phases.post_build.finally[0]=' echo "BUILD: post_build step successful"'
177
- ```
178
-
179
- Your output should be similar to the one below:
180
- ```
181
- ✅ Done
182
- ```
183
-
184
156
## Customize TerraHub Component for Google Cloud Function
185
157
186
158
Run the following command in terminal:
187
159
``` shell
188
160
terrahub configure -i demo_function -c component.template.terraform.backend.local.path=' /tmp/.terrahub/local_backend/demo_function/terraform.tfstate'
189
161
terrahub configure -i demo_function -c component.template.data.terraform_remote_state.storage.backend=' local'
190
162
terrahub configure -i demo_function -c component.template.data.terraform_remote_state.storage.config.path=' /tmp/.terrahub/local_backend/demo_storage_bucket/terraform.tfstate'
191
- terrahub configure -i demo_function -c component.template.data.terraform_remote_state.object.backend=' local'
192
- terrahub configure -i demo_function -c component.template.data.terraform_remote_state.object.config.path=' /tmp/.terrahub/local_backend/demo_object/terraform.tfstate'
163
+ 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.source=' ./demo.zip'
166
+ terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.depends_on[0]=' google_storage_bucket_object.demo_object'
193
167
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.name=' demofunction${local.project["code"]}'
194
168
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.region=' us-central1'
195
169
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.runtime=' nodejs8'
196
- terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.description=' My demo function ${data.terraform_remote_state.object.md5hash} '
170
+ terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.description=' My demo function'
197
171
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.available_memory_mb=128
198
172
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.source_archive_bucket=' ${data.terraform_remote_state.storage.thub_id}'
199
- terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.source_archive_object=' ${data.terraform_remote_state.object.output_name }'
173
+ terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.source_archive_object=' ${google_storage_bucket_object.demo_object.name }'
200
174
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.trigger_http=true
201
175
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.timeout=60
202
176
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.entry_point=' helloGET'
203
177
terrahub configure -i demo_function -c component.template.variable -D -y
204
178
terrahub configure -i demo_function -c component.template.output -D -y
205
179
terrahub configure -i demo_function -c component.template.output.id.value=' ${google_cloudfunctions_function.demo_function.id}'
206
180
terrahub configure -i demo_function -c component.template.output.trigger_url.value=' ${google_cloudfunctions_function.demo_function.https_trigger_url}'
181
+ 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
+ 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'
185
+ 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'
187
+ terrahub configure -i demo_function -c build.phases.pre_build.finally[0]=' echo "BUILD: pre_build step successful"'
188
+ 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'
191
+ terrahub configure -i demo_function -c build.phases.build.finally[0]=' echo "BUILD: build step successful"'
192
+ 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"'
194
+ terrahub configure -i demo_function -c build.phases.post_build.finally[0]=' echo "BUILD: post_build step successful"'
207
195
```
208
196
209
197
Your output should be similar to the one below:
@@ -222,16 +210,15 @@ Your output should be similar to the one below:
222
210
```
223
211
Project: demo-terraform-automation-google
224
212
└─ demo_storage_bucket_7b3c5d2c [path: ./demo_storage_bucket_7b3c5d2c]
225
- └─ demo_object_7b3c5d2c [path: ./demo_object_7b3c5d2c]
226
- └─ demo_function_7b3c5d2c [path: ./demo_function_7b3c5d2c]
213
+ └─ demo_function_7b3c5d2c [path: ./demo_function_7b3c5d2c]
227
214
```
228
215
229
216
230
217
## Run TerraHub Automation
231
218
232
219
Run the following command in terminal:
233
220
``` shell
234
- terrahub build -i demo_object
221
+ terrahub build -i demo_function
235
222
terrahub run -a -y
236
223
```
237
224
0 commit comments