Skip to content

Commit 5e4e27d

Browse files
committed
improving terrahub components naming
1 parent 3e22fb8 commit 5e4e27d

File tree

5 files changed

+87
-87
lines changed

5 files changed

+87
-87
lines changed

README.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ Your output should be similar to the one below:
113113

114114
Run the following command in terminal:
115115
```shell
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
116+
terrahub component -t google_storage_bucket -n google_storage \
117+
&& terrahub component -t google_cloudfunctions_function -n google_function -o ../google_storage
118118
```
119119

120120
Your output should be similar to the one below:
@@ -141,11 +141,11 @@ Your output should be similar to the one below:
141141

142142
Run the following command in terminal:
143143
```shell
144-
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.location='US'
147-
terrahub configure -i demo_storage_bucket -c component.template.resource.google_storage_bucket.demo_storage_bucket.project='${local.google_project_id}'
148-
terrahub configure -i demo_storage_bucket -c component.template.variable -D -y
144+
terrahub configure -i google_storage -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/google_storage/terraform.tfstate'
145+
terrahub configure -i google_storage -c component.template.resource.google_storage_bucket.google_storage.name='demo_terraform_automation_${local.project["code"]}'
146+
terrahub configure -i google_storage -c component.template.resource.google_storage_bucket.google_storage.location='US'
147+
terrahub configure -i google_storage -c component.template.resource.google_storage_bucket.google_storage.project='${local.google_project_id}'
148+
terrahub configure -i google_storage -c component.template.variable -D -y
149149
```
150150

151151
Your output should be similar to the one below:
@@ -157,41 +157,41 @@ Your output should be similar to the one below:
157157

158158
Run the following command in terminal:
159159
```shell
160-
terrahub configure -i demo_function -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/demo_function/terraform.tfstate'
161-
terrahub configure -i demo_function -c component.template.data.terraform_remote_state.storage.backend='local'
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'
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'
167-
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.name='demofunction${local.project["code"]}'
168-
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.region='us-central1'
169-
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.runtime='nodejs8'
170-
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.description='My demo function'
171-
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.available_memory_mb=128
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}'
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}'
174-
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.trigger_http=true
175-
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.timeout=60
176-
terrahub configure -i demo_function -c component.template.resource.google_cloudfunctions_function.demo_function.entry_point='helloGET'
177-
terrahub configure -i demo_function -c component.template.variable -D -y
178-
terrahub configure -i demo_function -c component.template.output -D -y
179-
terrahub configure -i demo_function -c component.template.output.id.value='${google_cloudfunctions_function.demo_function.id}'
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"'
160+
terrahub configure -i google_function -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/google_function/terraform.tfstate'
161+
terrahub configure -i google_function -c component.template.data.terraform_remote_state.storage.backend='local'
162+
terrahub configure -i google_function -c component.template.data.terraform_remote_state.storage.config.path='/tmp/.terrahub/local_backend/google_storage/terraform.tfstate'
163+
terrahub configure -i google_function -c component.template.resource.google_storage_bucket_object.google_storage_object.name='demo.zip'
164+
terrahub configure -i google_function -c component.template.resource.google_storage_bucket_object.google_storage_object.bucket='${data.terraform_remote_state.storage.thub_id}'
165+
terrahub configure -i google_function -c component.template.resource.google_storage_bucket_object.google_storage_object.source='./demo.zip'
166+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.depends_on[0]='google_storage_bucket_object.google_storage_object'
167+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.name='demofunction${local.project["code"]}'
168+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.region='us-central1'
169+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.runtime='nodejs8'
170+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.description='My demo function'
171+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.available_memory_mb=128
172+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.source_archive_bucket='${data.terraform_remote_state.storage.thub_id}'
173+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.source_archive_object='${google_storage_bucket_object.google_storage_object.name}'
174+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.trigger_http=true
175+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.timeout=60
176+
terrahub configure -i google_function -c component.template.resource.google_cloudfunctions_function.google_function.entry_point='helloGET'
177+
terrahub configure -i google_function -c component.template.variable -D -y
178+
terrahub configure -i google_function -c component.template.output -D -y
179+
terrahub configure -i google_function -c component.template.output.id.value='${google_cloudfunctions_function.google_function.id}'
180+
terrahub configure -i google_function -c component.template.output.trigger_url.value='${google_cloudfunctions_function.google_function.https_trigger_url}'
181+
terrahub configure -i google_function -c build.env.variables.THUB_FUNCTION_ZIP='demo.zip'
182+
terrahub configure -i google_function -c build.env.variables.THUB_BUILD_PATH='..'
183+
terrahub configure -i google_function -c build.env.variables.THUB_FUNCTION_TXT='demo.txt'
184+
terrahub configure -i google_function -c build.env.variables.THUB_BUILD_OK='true'
185+
terrahub configure -i google_function -c build.phases.pre_build.commands[0]='echo "BUILD: Running pre_build step"'
186+
terrahub configure -i google_function -c build.phases.pre_build.commands[1]='if [ ! -e "$THUB_FUNCTION_TXT" ]; then touch "$THUB_FUNCTION_TXT"; fi'
187+
terrahub configure -i google_function -c build.phases.pre_build.finally[0]='echo "BUILD: pre_build step successful"'
188+
terrahub configure -i google_function -c build.phases.build.commands[0]='echo "BUILD: Running build step"'
189+
terrahub configure -i google_function -c build.phases.build.commands[1]='if [ "$(head -n 1 "$THUB_FUNCTION_TXT")" != "$(stat -c %y "${THUB_BUILD_PATH}/demo.js")" ]; then zip -j ${THUB_FUNCTION_ZIP} ${THUB_BUILD_PATH}/demo.js; fi'
190+
terrahub configure -i google_function -c build.phases.build.commands[2]='if [ "$(head -n 1 "$THUB_FUNCTION_TXT")" != "$(stat -c %y "${THUB_BUILD_PATH}/demo.js")" ]; then terrahub configure -i google_function -c component.template.resource.google_storage_bucket_object.google_storage_object.name=$(date +%s).zip; fi'
191+
terrahub configure -i google_function -c build.phases.build.finally[0]='echo "BUILD: build step successful"'
192+
terrahub configure -i google_function -c build.phases.post_build.commands[0]='echo "BUILD: Running post_build step"'
193+
terrahub configure -i google_function -c build.phases.post_build.commands[1]='echo $(stat -c %y "${THUB_BUILD_PATH}/demo.js") > "$THUB_FUNCTION_TXT"'
194+
terrahub configure -i google_function -c build.phases.post_build.finally[0]='echo "BUILD: post_build step successful"'
195195
```
196196

197197
Your output should be similar to the one below:
@@ -209,16 +209,16 @@ terrahub graph
209209
Your output should be similar to the one below:
210210
```
211211
Project: demo-terraform-automation-google
212-
└─ demo_storage_bucket_7b3c5d2c [path: ./demo_storage_bucket_7b3c5d2c]
213-
└─ demo_function_7b3c5d2c [path: ./demo_function_7b3c5d2c]
212+
└─ google_storage [path: ./google_storage]
213+
└─ google_function [path: ./google_function]
214214
```
215215

216216

217217
## Run TerraHub Automation
218218

219219
Run the following command in terminal:
220220
```shell
221-
terrahub build -i demo_function
221+
terrahub build -i google_function
222222
terrahub run -a -y
223223
```
224224

index.js renamed to demo.js

File renamed without changes.

demo_storage_bucket/.terrahub.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
component:
2-
name: demo_function
2+
name: google_function
33
mapping:
44
- .
55
dependsOn:
6-
- ../demo_storage_bucket
6+
- ../google_storage
77
template:
88
resource:
99
google_cloudfunctions_function:
10-
demo_function:
10+
google_function:
1111
name: 'demofunction${local.project["code"]}'
1212
depends_on:
13-
- google_storage_bucket_object.demo_object
13+
- google_storage_bucket_object.google_storage_object
1414
region: us-central1
1515
runtime: nodejs8
1616
description: My demo function
1717
available_memory_mb: 128
1818
source_archive_bucket: '${data.terraform_remote_state.storage.thub_id}'
19-
source_archive_object: '${google_storage_bucket_object.demo_object.name}'
19+
source_archive_object: '${google_storage_bucket_object.google_storage_object.name}'
2020
trigger_http: true
2121
timeout: 60
2222
entry_point: helloGET
2323
google_storage_bucket_object:
24-
demo_object:
24+
google_storage_object:
2525
name: demo.zip
2626
bucket: '${data.terraform_remote_state.storage.thub_id}'
2727
source: ./demo.zip
2828
terraform:
2929
backend:
3030
local:
31-
path: /tmp/.terrahub/local_backend/demo_function/terraform.tfstate
31+
path: /tmp/.terrahub/local_backend/google_function/terraform.tfstate
3232
data:
3333
terraform_remote_state:
3434
storage:
3535
backend: local
3636
config:
37-
path: /tmp/.terrahub/local_backend/demo_storage_bucket/terraform.tfstate
37+
path: /tmp/.terrahub/local_backend/google_storage/terraform.tfstate
3838
output:
3939
id:
40-
value: '${google_cloudfunctions_function.demo_function.id}'
40+
value: '${google_cloudfunctions_function.google_function.id}'
4141
trigger_url:
42-
value: '${google_cloudfunctions_function.demo_function.https_trigger_url}'
42+
value: '${google_cloudfunctions_function.google_function.https_trigger_url}'
4343
build:
4444
env:
4545
variables:
@@ -59,21 +59,21 @@ build:
5959
- 'echo "BUILD: Running build step"'
6060
- >-
6161
if [ "$(head -n 1 "$THUB_FUNCTION_TXT")" != "$(stat -c %y
62-
"${THUB_BUILD_PATH}/index.js")" ]; then zip -j ${THUB_FUNCTION_ZIP}
63-
${THUB_BUILD_PATH}/index.js; fi
62+
"${THUB_BUILD_PATH}/demo.js")" ]; then zip -j ${THUB_FUNCTION_ZIP}
63+
${THUB_BUILD_PATH}/demo.js; fi
6464
- >-
6565
if [ "$(head -n 1 "$THUB_FUNCTION_TXT")" != "$(stat -c %y
66-
"${THUB_BUILD_PATH}/index.js")" ]; then terrahub configure -i
67-
demo_function -c
68-
component.template.resource.google_storage_bucket_object.demo_object.name=$(date
66+
"${THUB_BUILD_PATH}/demo.js")" ]; then terrahub configure -i
67+
google_function -c
68+
component.template.resource.google_storage_bucket_object.google_storage_object.name=$(date
6969
+%s).zip; fi
7070
finally:
7171
- 'echo "BUILD: build step successful"'
7272
post_build:
7373
commands:
7474
- 'echo "BUILD: Running post_build step"'
7575
- >-
76-
echo $(stat -c %y "${THUB_BUILD_PATH}/index.js") >
76+
echo $(stat -c %y "${THUB_BUILD_PATH}/demo.js") >
7777
"$THUB_FUNCTION_TXT"
7878
finally:
7979
- 'echo "BUILD: post_build step successful"'

google_storage/.terrahub.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
component:
2+
name: google_storage
3+
mapping:
4+
- .
5+
template:
6+
resource:
7+
google_storage_bucket:
8+
google_storage:
9+
name: 'demo_terraform_automation_${local.project["code"]}'
10+
location: US
11+
project: '${local.google_project_id}'
12+
output:
13+
id:
14+
value: '${google_storage_bucket.google_storage.id}'
15+
thub_id:
16+
value: '${google_storage_bucket.google_storage.id}'
17+
self_link:
18+
value: '${google_storage_bucket.google_storage.self_link}'
19+
project:
20+
value: '${google_storage_bucket.google_storage.project}'
21+
url:
22+
value: '${google_storage_bucket.google_storage.url}'
23+
terraform:
24+
backend:
25+
local:
26+
path: /tmp/.terrahub/local_backend/google_storage/terraform.tfstate

0 commit comments

Comments
 (0)