Skip to content

Commit 054f22a

Browse files
author
Vitalie Calmîc
authored
Merge pull request #32 from TerraHubCorp/dev
Upgrading code to terraform v0.12
2 parents 2fda921 + 69b4f86 commit 054f22a

Some content is hidden

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

49 files changed

+534
-511
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# IDEs
2+
.idea
3+
14
# Local hidden directories
25
**/.terraform/*
36
**/.backup/*
@@ -7,4 +10,4 @@
710
*.tfstate.*
811

912
# Zipped lambda function
10-
lambda/demo.*
13+
lambda/*.zip

.terrahub.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project:
2-
name: demo-terraform-automation-aws
2+
name: terraform-aws-automation-demo
33
code: 7356626c
44
include:
55
- .
@@ -9,16 +9,12 @@ project:
99
- '**/.git/**'
1010

1111
terraform:
12+
version: 0.12.19
1213
varFile:
1314
- default.tfvars
14-
version: 0.11.13
1515

1616
template:
17-
locals:
18-
account_id: 123456789012
19-
region: us-east-1
20-
provider:
21-
aws:
22-
region: '${local.region}'
23-
allowed_account_ids:
24-
- '${local.account_id}'
17+
terraform:
18+
backend:
19+
local:
20+
path: /tmp/.terrahub/local_backend/terraform-aws-automation-demo/${tfvar.terrahub["component"]["name"]}/terraform.tfstate

README.md

Lines changed: 34 additions & 208 deletions
Large diffs are not rendered by default.

api_gateway_deployment/.terrahub.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,3 @@ component:
22
name: api_gateway_deployment
33
dependsOn:
44
- api_gateway_rest_api
5-
template:
6-
resource:
7-
aws_api_gateway_deployment:
8-
api_gateway_deployment:
9-
rest_api_id: '${data.aws_api_gateway_rest_api.api_gateway_deployment.id}'
10-
stage_name: demo
11-
description: Managed by TerraHub
12-
stage_description: >-
13-
${format("%s %s", var.api_gateway_deployment_stage_name,
14-
timestamp())}
15-
variable:
16-
api_gateway_deployment_stage_name:
17-
type: string
18-
output:
19-
id:
20-
value: '${aws_api_gateway_deployment.api_gateway_deployment.id}'
21-
thub_id:
22-
value: '${aws_api_gateway_deployment.api_gateway_deployment.id}'
23-
invoke_url:
24-
value: '${aws_api_gateway_deployment.api_gateway_deployment.invoke_url}'
25-
execution_arn:
26-
value: '${aws_api_gateway_deployment.api_gateway_deployment.execution_arn}'
27-
created_date:
28-
value: '${aws_api_gateway_deployment.api_gateway_deployment.created_date}'
29-
terraform:
30-
backend:
31-
local:
32-
path: /tmp/.terrahub/local_backend/api_gateway_deployment/terraform.tfstate
33-
data:
34-
aws_api_gateway_rest_api:
35-
api_gateway_deployment:
36-
name: DemoApi7356626c
37-
tfvars:
38-
api_gateway_deployment_stage_name: 'Deployed at'

api_gateway_deployment/data.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "aws_api_gateway_rest_api" "api_gateway_deployment" {
2+
name = "DemoApi7356626c"
3+
}

api_gateway_deployment/default.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api_gateway_deployment_stage_name = "Deployed at"

api_gateway_deployment/locals.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
locals {
2+
region = "us-east-1"
3+
account_id = "123456789012"
4+
}

api_gateway_deployment/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "aws_api_gateway_deployment" "api_gateway_deployment" {
2+
rest_api_id = data.aws_api_gateway_rest_api.api_gateway_deployment.id
3+
stage_name = "demo"
4+
description = "Managed by TerraHub"
5+
stage_description = format("%s %s", var.api_gateway_deployment_stage_name, timestamp())
6+
}

api_gateway_deployment/output.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "thub_id" {
2+
value = aws_api_gateway_deployment.api_gateway_deployment.id
3+
}
4+
5+
output "invoke_url" {
6+
value = aws_api_gateway_deployment.api_gateway_deployment.invoke_url
7+
}
8+
9+
output "execution_arn" {
10+
value = aws_api_gateway_deployment.api_gateway_deployment.execution_arn
11+
}
12+
13+
output "created_date" {
14+
value = aws_api_gateway_deployment.api_gateway_deployment.created_date
15+
}
16+
17+
output "id" {
18+
value = aws_api_gateway_deployment.api_gateway_deployment.id
19+
}

api_gateway_deployment/provider.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
provider "aws" {
2+
version = "~> 2.44"
3+
region = local.region
4+
5+
allowed_account_ids = [
6+
local.account_id
7+
]
8+
}

api_gateway_deployment/variable.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "api_gateway_deployment_stage_name" {
2+
type = string
3+
}

api_gateway_rest_api/.terrahub.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,3 @@ component:
44
- lambda
55
mapping:
66
- ../api_swagger.json.tpl
7-
template:
8-
resource:
9-
aws_api_gateway_rest_api:
10-
api_gateway_rest_api:
11-
name: DemoApi7356626c
12-
body: '${data.template_file.swagger.rendered}}'
13-
description: Managed by TerraHub
14-
output:
15-
id:
16-
value: '${aws_api_gateway_rest_api.api_gateway_rest_api.id}'
17-
thub_id:
18-
value: '${aws_api_gateway_rest_api.api_gateway_rest_api.id}'
19-
root_resource_id:
20-
value: '${aws_api_gateway_rest_api.api_gateway_rest_api.root_resource_id}'
21-
execution_arn:
22-
value: '${aws_api_gateway_rest_api.api_gateway_rest_api.execution_arn}'
23-
endpoint_configuration:
24-
value: >-
25-
${aws_api_gateway_rest_api.api_gateway_rest_api.endpoint_configuration}
26-
created_date:
27-
value: '${aws_api_gateway_rest_api.api_gateway_rest_api.created_date}'
28-
terraform:
29-
backend:
30-
local:
31-
path: /tmp/.terrahub/local_backend/api_gateway_rest_api/terraform.tfstate
32-
data:
33-
template_file:
34-
swagger:
35-
template: '${file("${local.project["path"]}/api_swagger.json.tpl")}'
36-
vars: '${map("account_id","${local.account_id}")}'

api_gateway_rest_api/data.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
data "template_file" "swagger" {
2+
template = file(format("%s/api_swagger.json.tpl", local.project["path"]))
3+
vars = map("account_id", local.account_id)
4+
}

api_gateway_rest_api/locals.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
locals {
2+
region = "us-east-1"
3+
account_id = "123456789012"
4+
}

api_gateway_rest_api/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resource "aws_api_gateway_rest_api" "api_gateway_rest_api" {
2+
body = data.template_file.swagger.rendered
3+
description = "Managed by TerraHub"
4+
name = "DemoApi7356626c"
5+
}

api_gateway_rest_api/output.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
output "thub_id" {
2+
value = aws_api_gateway_rest_api.api_gateway_rest_api.id
3+
}
4+
5+
output "root_resource_id" {
6+
value = aws_api_gateway_rest_api.api_gateway_rest_api.root_resource_id
7+
}
8+
9+
output "execution_arn" {
10+
value = aws_api_gateway_rest_api.api_gateway_rest_api.execution_arn
11+
}
12+
13+
output "endpoint_configuration" {
14+
value = aws_api_gateway_rest_api.api_gateway_rest_api.endpoint_configuration
15+
}
16+
17+
output "created_date" {
18+
value = aws_api_gateway_rest_api.api_gateway_rest_api.created_date
19+
}
20+
21+
output "id" {
22+
value = aws_api_gateway_rest_api.api_gateway_rest_api.id
23+
}

api_gateway_rest_api/provider.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
provider "aws" {
2+
version = "~> 2.44"
3+
region = local.region
4+
5+
allowed_account_ids = [
6+
local.account_id
7+
]
8+
}

iam_role/.terrahub.yml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,3 @@ component:
33
mapping:
44
- ../iam_assume_policy.json.tpl
55
- ../iam_trust_policy.json.tpl
6-
template:
7-
resource:
8-
aws_iam_role:
9-
iam_role:
10-
assume_role_policy: '${file("${local.project["path"]}/iam_trust_policy.json.tpl")}'
11-
description: Managed by TerraHub
12-
force_detach_policies: false
13-
name: DemoAWSLambdaExecRole7356626c
14-
path: /
15-
aws_iam_role_policy:
16-
iam_role:
17-
name: DemoAWSLambdaExecPolicy7356626c
18-
policy: '${data.template_file.iam_role_policy.rendered}'
19-
role: '${aws_iam_role.iam_role.id}'
20-
output:
21-
id:
22-
value: '${aws_iam_role.iam_role.id}'
23-
thub_id:
24-
value: '${aws_iam_role.iam_role.id}'
25-
create_date:
26-
value: '${aws_iam_role.iam_role.create_date}'
27-
unique_id:
28-
value: '${aws_iam_role.iam_role.unique_id}'
29-
name:
30-
value: '${aws_iam_role.iam_role.name}'
31-
arn:
32-
value: '${aws_iam_role.iam_role.arn}'
33-
terraform:
34-
backend:
35-
local:
36-
path: /tmp/.terrahub/local_backend/iam_role/terraform.tfstate
37-
data:
38-
template_file:
39-
iam_role_policy:
40-
template: '${file("${local.project["path"]}/iam_assume_policy.json.tpl")}'
41-
vars: '${map("account_id","${local.account_id}")}'

iam_role/data.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
data "template_file" "iam_role_policy" {
2+
template = file(format("%s/iam_assume_policy.json.tpl", local.project["path"]))
3+
vars = map("account_id", local.account_id)
4+
}

iam_role/locals.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
locals {
2+
region = "us-east-1"
3+
account_id = "123456789012"
4+
}

iam_role/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resource "aws_iam_role_policy" "iam_role" {
2+
name = "DemoAWSLambdaExecPolicy7356626c"
3+
policy = data.template_file.iam_role_policy.rendered
4+
role = aws_iam_role.iam_role.id
5+
}
6+
7+
resource "aws_iam_role" "iam_role" {
8+
assume_role_policy = file(format("%s/iam_trust_policy.json.tpl", local.project["path"]))
9+
description = "Managed by TerraHub"
10+
force_detach_policies = false
11+
name = "DemoAWSLambdaExecRole7356626c"
12+
path = "/"
13+
}

iam_role/output.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
output "id" {
2+
value = aws_iam_role.iam_role.id
3+
}
4+
5+
output "thub_id" {
6+
value = aws_iam_role.iam_role.id
7+
}
8+
9+
output "create_date" {
10+
value = aws_iam_role.iam_role.create_date
11+
}
12+
13+
output "unique_id" {
14+
value = aws_iam_role.iam_role.unique_id
15+
}
16+
17+
output "name" {
18+
value = aws_iam_role.iam_role.name
19+
}
20+
21+
output "arn" {
22+
value = aws_iam_role.iam_role.arn
23+
}

iam_role/provider.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
provider "aws" {
2+
version = "~> 2.44"
3+
region = local.region
4+
5+
allowed_account_ids = [
6+
local.account_id
7+
]
8+
}

lambda/.terrahub.yml

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,12 @@ component:
44
- iam_role
55
- security_group
66
- subnet_private
7-
template:
8-
resource:
9-
aws_lambda_function:
10-
lambda:
11-
function_name: DemoAWSLambda7356626c
12-
handler: demo.handler
13-
runtime: nodejs8.10
14-
role: '${data.terraform_remote_state.iam.arn}'
15-
filename: '${local.component["path"]}/demo.zip'
16-
description: Managed by TerraHub
17-
memory_size: 512
18-
publish: false
19-
source_code_hash: '${base64sha256(file("${local.component["path"]}/demo.zip"))}'
20-
timeout: 300
21-
vpc_config:
22-
security_group_ids:
23-
- '${data.terraform_remote_state.sg.thub_id}'
24-
subnet_ids:
25-
- '${data.terraform_remote_state.subnet.thub_id}'
26-
tags: >-
27-
${map("Description","Managed by TerraHub",
28-
"Name","demo-terraform-automation-aws", "ThubCode","7356626c",
29-
"ThubEnv","default")}
30-
dynamic:
31-
data:
32-
terraform_remote_state:
33-
- component: iam_role
34-
name: iam
35-
- component: security_group
36-
name: sg
37-
- component: subnet_private
38-
name: subnet
39-
output:
40-
id:
41-
value: '${aws_lambda_function.lambda.id}'
42-
thub_id:
43-
value: '${aws_lambda_function.lambda.id}'
44-
qualified_arn:
45-
value: '${aws_lambda_function.lambda.qualified_arn}'
46-
invoke_arn:
47-
value: '${aws_lambda_function.lambda.invoke_arn}'
48-
source_code_hash:
49-
value: '${aws_lambda_function.lambda.source_code_hash}'
50-
tracing_config:
51-
value: '${aws_lambda_function.lambda.tracing_config}'
52-
source_code_size:
53-
value: '${aws_lambda_function.lambda.source_code_size}'
54-
version:
55-
value: '${aws_lambda_function.lambda.version}'
56-
last_modified:
57-
value: '${aws_lambda_function.lambda.last_modified}'
58-
arn:
59-
value: '${aws_lambda_function.lambda.arn}'
60-
terraform:
61-
backend:
62-
local:
63-
path: /tmp/.terrahub/local_backend/lambda/terraform.tfstate
647
build:
658
env:
669
variables:
6710
THUB_ENV: dev
6811
THUB_LAMBDA_ZIP: demo.zip
69-
THUB_BUILD_PATH: ..
12+
THUB_BUILD_PATH: ../..
7013
THUB_BUILD_OK: true
7114
phases:
7215
post_build:

0 commit comments

Comments
 (0)