TerraHub Structure

Terraform compatible declaration

In order to be able to switch between terrahub and pure terraform the only thing you have to add - .terrahub.yml per component.
1
your-project
2
├─ .terrahub
3
│ ├─ s3
4
│ │ ├── .terrahub.yml
5
│ │ ├── README.md
6
│ │ ├── default.tfvars
7
│ │ ├── main.tf
8
│ │ ├── output.tf
9
│ │ ├── provider.tf
10
│ │ └── variables.tf
11
│ ├─ cloudfront
12
│ │ ├── .terrahub.yml
13
│ │ ├── README.md
14
│ │ ├── default.tfvars
15
│ │ ├── main.tf
16
│ │ ├── output.tf
17
│ │ ├── provider.tf
18
│ │ └── variables.tf
19
├─ .terrahub.yml
20
├─ src
21
└─ ...
Copied!
NOTE: AVOID terraform configurations in root of your project!

Terrahub specific declaration

If you decided to use terrahub and not going to switch back to plain terraform, you can declare everything in .terrahub.yml as component template:
1
component:
2
name: 'terrahub_component'
3
template:
4
provider:
5
aws:
6
profile: 'saml'
7
region: '${var.region}'
8
9
variable:
10
region:
11
description: 'This is the AWS region.'
12
13
tfvars:
14
region: 'us-east-1'
15
16
data:
17
aws_iam_policy_document:
18
terrahub_component_assume_role_policy:
19
statement:
20
- actions: ['sts:AssumeRole']
21
principals:
22
type: 'Service'
23
identifiers: ['*']
24
25
resource:
26
aws_iam_role:
27
terrahub_component_role:
28
name: 'terrahub_component_assume_role'
29
assume_role_policy: '${data.aws_iam_policy_document.terrahub_component_assume_role_policy.json}'
Copied!
To make working with terrahub a pleasure we also adding into locals some additional info like:
1
{
2
"timestamp": 1544222111000,
3
"component": {
4
"name": "terrahub_component",
5
"path": "/User/username/projects/current/terrahub_component",
6
"local": "/tmp/.terrahub/local_tfstate/owner/terrahub_docs",
7
"remote": "terraform/owner/terrahub_docs"
8
},
9
"project": {
10
"path": "/User/username/projects/current",
11
"name": "terrahub_docs",
12
"code": "abcd1234"
13
}
14
}
Copied!