Skip to content

Commit

Permalink
Merge pull request #8 from TerraHubCorp/dev
Browse files Browse the repository at this point in the history
Transform HCL into TerraHub config with template
  • Loading branch information
iasha102 authored Feb 15, 2019
2 parents b5695d0 + 6fe593c commit 9247ee0
Show file tree
Hide file tree
Showing 44 changed files with 183 additions and 492 deletions.
21 changes: 11 additions & 10 deletions .terrahub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
project:
name: demo-terraform-automation-google
code: f2754a99
include:
- '.'
exclude:
- '**/.terraform/*'
- '**/node_modules/*'
include: ['.']
exclude: ['**/.terraform/*', '**/node_modules/*']

## terraform config
terraform:
varFile:
- default.tfvars
var:
## template config
template:
provider:
google: {}
locals:
google_project_id: project-123456789012
google_region: us-central1
google_org_id: 123456789012
google_service_account_name: demo-team
google_billing_account: 123456-ABCDEF-ZYXWVU
google_location_id: us-central

## terraform config
terraform:
varFile: ['default.tfvars']
version: 0.11.7
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Run the following command in terminal:
gcloud auth login
```

> NOTE: If you don't have Google Cloud CLI, check out
> NOTE: If you don't have Google Cloud CLI, check out this
[installation guide](https://cloud.google.com/sdk/install)

## Setup Environment Variables (Will Be Used Later)
Expand All @@ -30,7 +30,7 @@ Automated Setup (run the following command in terminal):
export ORG_ID="$(gcloud organizations list --format=json | jq '.[0].name[14:]')"
```

> NOTE: If you don't have JQ CLI, check out
> NOTE: If you don't have JQ CLI, check out this
[installation guide](https://stedolan.github.io/jq/download/)

### Setup BILLING_ID Programmatically
Expand All @@ -40,7 +40,7 @@ Automated Setup (run the following command in terminal):
export BILLING_ID="$(gcloud beta billing accounts list --format=json | jq '.[0].name[16:]')"
```

> NOTE: If you don't have JQ CLI, check out
> NOTE: If you don't have JQ CLI, check out this
[installation guide](https://stedolan.github.io/jq/download/)

## Create Google Cloud Project & Billing
Expand Down Expand Up @@ -123,10 +123,10 @@ Your output should be similar to the one below:
```
Usage: terrahub [command] [options]
terrahub@0.0.28 (built: 2018-10-11T12:33:57.775Z)
terrahub@0.1.28 (built: 2019-02-08T17:17:41.912Z)
```

> NOTE: If you don't have TerraHub CLI, check out
> NOTE: If you don't have TerraHub CLI, check out this
[installation guide](https://www.npmjs.com/package/terrahub)

Run the following command in terminal:
Expand Down Expand Up @@ -180,9 +180,9 @@ Project: demo-terraform-google

Run the following command in terminal:
```shell
terrahub configure -c terraform.var.google_org_id="${ORG_ID}"
terrahub configure -c terraform.var.google_billing_account="${BILLING_ID}"
terrahub configure -c terraform.var.google_project_id="${GOOGLE_CLOUD_PROJECT}"
terrahub configure -c template.locals.google_org_id="${ORG_ID}"
terrahub configure -c template.locals.google_billing_account="${BILLING_ID}"
terrahub configure -c template.locals.google_project_id="${GOOGLE_CLOUD_PROJECT}"
```

Your output should be similar to the one below:
Expand Down
43 changes: 39 additions & 4 deletions project/.terrahub.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
## local config
component:
name: 'project'

ci:
mapping:
- '.'
mapping: ['.']
template:
resource:
google_project:
project:
project_id: ${local.google_project_id}
org_id: ${local.google_org_id}
billing_account: ${local.google_billing_account}
name: ${var.google_project_name}
auto_create_network: ${var.google_project_auto_create_network}
folder_id: ${var.google_project_folder_id}
labels: ${merge(var.default_labels, var.custom_labels)}
output:
number:
value: ${google_project.project.number}
variable:
google_project_name:
type: string
google_project_folder_id:
type: string
google_project_skip_delete:
type: string
google_project_auto_create_network:
type: string
custom_labels:
type: map
default_labels:
type: map
tfvars:
custom_labels: {}
default_labels:
description: managed-by-terrahub
name: project
thubcode: f2754a99
thubenv: default
google_project_auto_create_network: true
google_project_folder_id: ""
google_project_name: project
google_project_skip_delete: false
35 changes: 0 additions & 35 deletions project/README.md

This file was deleted.

24 changes: 0 additions & 24 deletions project/default.tfvars

This file was deleted.

15 changes: 0 additions & 15 deletions project/main.tf

This file was deleted.

5 changes: 0 additions & 5 deletions project/output.tf

This file was deleted.

2 changes: 0 additions & 2 deletions project/provider.tf

This file was deleted.

52 changes: 0 additions & 52 deletions project/variables.tf

This file was deleted.

28 changes: 23 additions & 5 deletions project_iam_binding_compute_admin/.terrahub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
## local config
component:
name: 'project_iam_binding_compute_admin'
mapping: ['.']
dependsOn:
- '../project_iam_member'

ci:
mapping:
- '.'
- '../project_iam_member'
template:
resource:
google_project_iam_binding:
project_iam_binding_compute_admin:
project: ${local.google_project_id}
members: ${var.google_project_members}
role: ${var.google_project_role}
output:
etag:
value: ${google_project_iam_binding.project_iam_binding_compute_admin.etag}
provider:
google: {}
variable:
google_project_role:
type: string
google_project_members:
type: list
tfvars:
google_project_members:
- [email protected]
google_project_role: roles/compute.instanceAdmin
19 changes: 0 additions & 19 deletions project_iam_binding_compute_admin/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions project_iam_binding_compute_admin/default.tfvars

This file was deleted.

5 changes: 0 additions & 5 deletions project_iam_binding_compute_admin/main.tf

This file was deleted.

5 changes: 0 additions & 5 deletions project_iam_binding_compute_admin/output.tf

This file was deleted.

2 changes: 0 additions & 2 deletions project_iam_binding_compute_admin/provider.tf

This file was deleted.

18 changes: 0 additions & 18 deletions project_iam_binding_compute_admin/variables.tf

This file was deleted.

Loading

0 comments on commit 9247ee0

Please sign in to comment.