-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from TerraHubCorp/dev
Transform HCL into TerraHub config with template
- Loading branch information
Showing
12 changed files
with
219 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
# Local .terraform directories | ||
# Local hidden directories | ||
**/.terraform/* | ||
**/.backup/* | ||
|
||
# .tfstate files | ||
**/*.tf* | ||
# Local .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Zipped google function | ||
google_function/demo.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
## project config | ||
project: | ||
name: demo-terraform-automation-google | ||
code: f2754a99 | ||
include: ['.'] | ||
exclude: ['**/.terraform/*', '**/node_modules/*'] | ||
|
||
## template config | ||
code: 7b3c5d2c | ||
include: | ||
- . | ||
exclude: | ||
- '**/.terraform/**' | ||
- '**/node_modules/**' | ||
- '**/.git/**' | ||
terraform: | ||
varFile: | ||
- default.tfvars | ||
version: 0.11.11 | ||
template: | ||
provider: | ||
google: {} | ||
locals: | ||
google_project_id: project-123456789012 | ||
google_region: us-central1 | ||
google_org_id: 123456789012 | ||
google_service_account_name: demo-team | ||
google_project_id: terrahub-123456 | ||
google_billing_account: 123456-ABCDEF-ZYXWVU | ||
google_location_id: us-central | ||
|
||
## terraform config | ||
terraform: | ||
varFile: ['default.tfvars'] | ||
version: 0.11.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
component: | ||
name: google_function | ||
mapping: | ||
- . | ||
dependsOn: | ||
- ../google_storage | ||
template: | ||
resource: | ||
google_cloudfunctions_function: | ||
google_function: | ||
name: 'demofunction${local.project["code"]}' | ||
depends_on: | ||
- google_storage_bucket_object.google_storage_object | ||
region: us-central1 | ||
runtime: nodejs8 | ||
description: My demo function | ||
available_memory_mb: 128 | ||
source_archive_bucket: '${data.terraform_remote_state.storage.thub_id}' | ||
source_archive_object: '${google_storage_bucket_object.google_storage_object.name}' | ||
trigger_http: true | ||
timeout: 60 | ||
entry_point: helloGET | ||
google_storage_bucket_object: | ||
google_storage_object: | ||
name: demo.zip | ||
bucket: '${data.terraform_remote_state.storage.thub_id}' | ||
source: ./demo.zip | ||
terraform: | ||
backend: | ||
local: | ||
path: /tmp/.terrahub/local_backend/google_function/terraform.tfstate | ||
data: | ||
terraform_remote_state: | ||
storage: | ||
backend: local | ||
config: | ||
path: /tmp/.terrahub/local_backend/google_storage/terraform.tfstate | ||
output: | ||
id: | ||
value: '${google_cloudfunctions_function.google_function.id}' | ||
trigger_url: | ||
value: '${google_cloudfunctions_function.google_function.https_trigger_url}' | ||
build: | ||
env: | ||
variables: | ||
THUB_FUNCTION_ZIP: demo.zip | ||
THUB_BUILD_PATH: .. | ||
THUB_FUNCTION_TXT: demo.txt | ||
THUB_BUILD_OK: true | ||
phases: | ||
pre_build: | ||
commands: | ||
- 'echo "BUILD: Running pre_build step"' | ||
- 'if [ ! -e "$THUB_FUNCTION_TXT" ]; then touch "$THUB_FUNCTION_TXT"; fi' | ||
finally: | ||
- 'echo "BUILD: pre_build step successful"' | ||
build: | ||
commands: | ||
- 'echo "BUILD: Running build step"' | ||
- >- | ||
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 | ||
- >- | ||
if [ "$(head -n 1 "$THUB_FUNCTION_TXT")" != "$(stat -c %y | ||
"${THUB_BUILD_PATH}/index.js")" ]; then terrahub configure -i | ||
google_function -c | ||
component.template.resource.google_storage_bucket_object.google_storage_object.name=$(date | ||
+%s).zip; fi | ||
finally: | ||
- 'echo "BUILD: build step successful"' | ||
post_build: | ||
commands: | ||
- 'echo "BUILD: Running post_build step"' | ||
- >- | ||
echo $(stat -c %y "${THUB_BUILD_PATH}/index.js") > | ||
"$THUB_FUNCTION_TXT" | ||
finally: | ||
- 'echo "BUILD: post_build step successful"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
component: | ||
name: google_storage | ||
mapping: | ||
- . | ||
template: | ||
resource: | ||
google_storage_bucket: | ||
google_storage: | ||
name: 'demo_terraform_automation_${local.project["code"]}' | ||
location: US | ||
project: '${local.google_project_id}' | ||
output: | ||
id: | ||
value: '${google_storage_bucket.google_storage.id}' | ||
thub_id: | ||
value: '${google_storage_bucket.google_storage.id}' | ||
self_link: | ||
value: '${google_storage_bucket.google_storage.self_link}' | ||
project: | ||
value: '${google_storage_bucket.google_storage.project}' | ||
url: | ||
value: '${google_storage_bucket.google_storage.url}' | ||
terraform: | ||
backend: | ||
local: | ||
path: /tmp/.terrahub/local_backend/google_storage/terraform.tfstate |
Oops, something went wrong.