Skip to content

Commit 9247ee0

Browse files
authored
Merge pull request #8 from TerraHubCorp/dev
Transform HCL into TerraHub config with template
2 parents b5695d0 + 6fe593c commit 9247ee0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+183
-492
lines changed

.terrahub.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
project:
33
name: demo-terraform-automation-google
44
code: f2754a99
5-
include:
6-
- '.'
7-
exclude:
8-
- '**/.terraform/*'
9-
- '**/node_modules/*'
5+
include: ['.']
6+
exclude: ['**/.terraform/*', '**/node_modules/*']
107

11-
## terraform config
12-
terraform:
13-
varFile:
14-
- default.tfvars
15-
var:
8+
## template config
9+
template:
10+
provider:
11+
google: {}
12+
locals:
1613
google_project_id: project-123456789012
1714
google_region: us-central1
1815
google_org_id: 123456789012
1916
google_service_account_name: demo-team
2017
google_billing_account: 123456-ABCDEF-ZYXWVU
2118
google_location_id: us-central
19+
20+
## terraform config
21+
terraform:
22+
varFile: ['default.tfvars']
2223
version: 0.11.7

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Run the following command in terminal:
77
gcloud auth login
88
```
99

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

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

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

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

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

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

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

132132
Run the following command in terminal:
@@ -180,9 +180,9 @@ Project: demo-terraform-google
180180

181181
Run the following command in terminal:
182182
```shell
183-
terrahub configure -c terraform.var.google_org_id="${ORG_ID}"
184-
terrahub configure -c terraform.var.google_billing_account="${BILLING_ID}"
185-
terrahub configure -c terraform.var.google_project_id="${GOOGLE_CLOUD_PROJECT}"
183+
terrahub configure -c template.locals.google_org_id="${ORG_ID}"
184+
terrahub configure -c template.locals.google_billing_account="${BILLING_ID}"
185+
terrahub configure -c template.locals.google_project_id="${GOOGLE_CLOUD_PROJECT}"
186186
```
187187

188188
Your output should be similar to the one below:

project/.terrahub.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
11
## local config
22
component:
33
name: 'project'
4-
5-
ci:
6-
mapping:
7-
- '.'
4+
mapping: ['.']
5+
template:
6+
resource:
7+
google_project:
8+
project:
9+
project_id: ${local.google_project_id}
10+
org_id: ${local.google_org_id}
11+
billing_account: ${local.google_billing_account}
12+
name: ${var.google_project_name}
13+
auto_create_network: ${var.google_project_auto_create_network}
14+
folder_id: ${var.google_project_folder_id}
15+
labels: ${merge(var.default_labels, var.custom_labels)}
16+
output:
17+
number:
18+
value: ${google_project.project.number}
19+
variable:
20+
google_project_name:
21+
type: string
22+
google_project_folder_id:
23+
type: string
24+
google_project_skip_delete:
25+
type: string
26+
google_project_auto_create_network:
27+
type: string
28+
custom_labels:
29+
type: map
30+
default_labels:
31+
type: map
32+
tfvars:
33+
custom_labels: {}
34+
default_labels:
35+
description: managed-by-terrahub
36+
name: project
37+
thubcode: f2754a99
38+
thubenv: default
39+
google_project_auto_create_network: true
40+
google_project_folder_id: ""
41+
google_project_name: project
42+
google_project_skip_delete: false

project/README.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

project/default.tfvars

Lines changed: 0 additions & 24 deletions
This file was deleted.

project/main.tf

Lines changed: 0 additions & 15 deletions
This file was deleted.

project/output.tf

Lines changed: 0 additions & 5 deletions
This file was deleted.

project/provider.tf

Lines changed: 0 additions & 2 deletions
This file was deleted.

project/variables.tf

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
## local config
22
component:
33
name: 'project_iam_binding_compute_admin'
4+
mapping: ['.']
45
dependsOn:
5-
- '../project_iam_member'
6-
7-
ci:
8-
mapping:
9-
- '.'
6+
- '../project_iam_member'
7+
template:
8+
resource:
9+
google_project_iam_binding:
10+
project_iam_binding_compute_admin:
11+
project: ${local.google_project_id}
12+
members: ${var.google_project_members}
13+
role: ${var.google_project_role}
14+
output:
15+
etag:
16+
value: ${google_project_iam_binding.project_iam_binding_compute_admin.etag}
17+
provider:
18+
google: {}
19+
variable:
20+
google_project_role:
21+
type: string
22+
google_project_members:
23+
type: list
24+
tfvars:
25+
google_project_members:
26+
- demo@gmail.com
27+
google_project_role: roles/compute.instanceAdmin

0 commit comments

Comments
 (0)