Skip to content

Commit cc21859

Browse files
authored
Merge pull request #5 from TerraHubCorp/dev
Transform HCL into TerraHub config with template
2 parents b5dc20d + e6b0004 commit cc21859

Some content is hidden

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

53 files changed

+236
-788
lines changed

.terrahub.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
project:
33
name: demo-terraform-automation-aws
44
code: 7356626c
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+
locals:
1611
account_id: 123456789012
1712
region: us-east-1
13+
provider:
14+
aws:
15+
region: '${local.region}'
16+
allowed_account_ids: ['${local.account_id}']
17+
18+
## terraform config
19+
terraform:
20+
varFile: ['default.tfvars']
21+
version: 0.11.7

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Your output should be similar to the one below:
7070
```
7171
Usage: terrahub [command] [options]
7272
73-
terrahub@0.0.28 (built: 2018-10-11T12:33:57.775Z)
73+
terrahub@0.1.28 (built: 2019-02-08T17:17:41.912Z)
7474
```
7575

7676
> NOTE: If you don't have TerraHub CLI, check out
@@ -129,8 +129,8 @@ Project: demo-terraform-aws
129129

130130
Run the following command in terminal:
131131
```shell
132-
terrahub configure -c terraform.var.account_id="${AWS_ACCOUNT_ID}"
133-
terrahub configure -c terraform.var.region="${AWS_DEFAULT_REGION}"
132+
terrahub configure -c template.locals.account_id="${AWS_ACCOUNT_ID}"
133+
terrahub configure -c template.locals.region="${AWS_DEFAULT_REGION}"
134134
```
135135

136136
Your output should be similar to the one below:

iam_group/.terrahub.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
## local config
22
component:
33
name: 'iam_group'
4-
dependsOn:
5-
- '../iam_policy'
6-
7-
## ci config
8-
ci:
9-
mapping:
10-
- '.'
4+
mapping: ['.']
5+
dependsOn: ['../iam_policy']
6+
template:
7+
resource:
8+
aws_iam_group:
9+
iam_group:
10+
name: ${var.iam_group_name}
11+
path: ${var.iam_group_path}
12+
output:
13+
id:
14+
value: ${aws_iam_group.iam_group.id}
15+
thub_id:
16+
value: ${aws_iam_group.iam_group.id}
17+
arn:
18+
value: ${aws_iam_group.iam_group.arn}
19+
name:
20+
value: ${aws_iam_group.iam_group.name}
21+
path:
22+
value: ${aws_iam_group.iam_group.path}
23+
unique_id:
24+
value: ${aws_iam_group.iam_group.unique_id}
25+
variable:
26+
iam_group_name:
27+
type: string
28+
iam_group_path:
29+
type: string
30+
tfvars:
31+
iam_group_name: iam_group
32+
iam_group_path: /

iam_group/README.md

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

iam_group/default.tfvars

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

iam_group/main.tf

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

iam_group/output.tf

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

iam_group/provider.tf

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

iam_group/variables.tf

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

iam_policy/.terrahub.yml

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
11
## local config
22
component:
33
name: 'iam_policy'
4-
dependsOn:
5-
- '../iam_role'
6-
7-
## ci config
8-
ci:
9-
mapping:
10-
- '.'
4+
mapping: ['.']
5+
dependsOn: ['../iam_role']
6+
template:
7+
data:
8+
aws_iam_policy_document:
9+
iam_policy:
10+
statement:
11+
- sid: ${var.iam_policy_sid}
12+
actions: ${split(",",var.iam_policy_actions)}
13+
resources: ${split(",",var.iam_policy_resources)}
14+
resource:
15+
aws_iam_policy:
16+
iam_policy:
17+
description: ${var.iam_policy_description}
18+
name: ${var.iam_policy_name}
19+
path: ${var.iam_policy_path}
20+
policy: ${data.aws_iam_policy_document.iam_policy.json}
21+
output:
22+
id:
23+
value: ${aws_iam_policy.iam_policy.id}
24+
thub_id:
25+
value: ${aws_iam_policy.iam_policy.id}
26+
arn:
27+
value: ${aws_iam_policy.iam_policy.arn}
28+
name:
29+
value: ${aws_iam_policy.iam_policy.name}
30+
path:
31+
value: ${aws_iam_policy.iam_policy.path}
32+
policy:
33+
value: ${aws_iam_policy.iam_policy.policy}
34+
variable:
35+
iam_policy_name:
36+
type: string
37+
iam_policy_description:
38+
type: string
39+
iam_policy_path:
40+
type: string
41+
iam_policy_sid:
42+
type: string
43+
iam_policy_actions:
44+
type: string
45+
iam_policy_resources:
46+
type: string
47+
tfvars:
48+
iam_policy_actions: lambda:*
49+
iam_policy_description: Managed by TerraHub
50+
iam_policy_name: iam_policy
51+
iam_policy_path: /
52+
iam_policy_resources: '*'
53+
iam_policy_sid: default

iam_policy/README.md

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

iam_policy/data.tf

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

iam_policy/default.tfvars

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

iam_policy/main.tf

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

iam_policy/output.tf

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

iam_policy/provider.tf

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

0 commit comments

Comments
 (0)