Skip to content

Commit 05c1b83

Browse files
authored
Merge pull request #9 from TerraHubCorp/dev
Improve readme
2 parents 991488c + fffdda4 commit 05c1b83

File tree

2 files changed

+62
-15
lines changed

2 files changed

+62
-15
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
*.tfstate.*
88

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

README.md

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
# Terraform Automation using AWS Provider
1+
# Terraform Automation Demo using AWS Cloud Provider
2+
3+
The purpose of this repository is to show case terraform automation for AWS
4+
Cloud. This demo will provision the following cloud resources associated to
5+
corresponding terraform configurations:
6+
7+
| AWS Resource | Terraform Resource | Link to TerraHub Config |
8+
|-----------------------|--------------------|-------------------------|
9+
| API Gateway Deployment | aws_api_gateway_deployment | https://github.com/TerraHubCorp/demo-terraform-automation-aws/blob/master/api_gateway_deployment/.terrahub.yml#L9 |
10+
| API Gateway REST API | aws_api_gateway_rest_api | https://github.com/TerraHubCorp/demo-terraform-automation-aws/blob/master/api_gateway_rest_api/.terrahub.yml#L9 |
11+
| IAM Role | aws_iam_role | https://github.com/TerraHubCorp/demo-terraform-automation-aws/blob/master/iam_role/.terrahub.yml#L8 |
12+
| Lambda Function | aws_lambda_function | https://github.com/TerraHubCorp/demo-terraform-automation-aws/blob/master/lambda/.terrahub.yml#L11 |
13+
| Security Group | aws_security_group | https://github.com/TerraHubCorp/demo-terraform-automation-aws/blob/master/security_group/.terrahub.yml#L9 |
14+
| Subnet | aws_subnet | https://github.com/TerraHubCorp/demo-terraform-automation-aws/blob/master/subnet_private/.terrahub.yml#L9 |
15+
| VPC | aws_vpc | https://github.com/TerraHubCorp/demo-terraform-automation-aws/blob/master/vpc/.terrahub.yml#L7 |
16+
17+
Follow below instructions to try this out in your own AWS Cloud account.
218

319
## Create IAM User
420
1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/
@@ -39,7 +55,7 @@ Default output format [None]: json
3955

4056
## Setup Environment Variables (Will Be Used Later)
4157

42-
Manual Setup (set values in double quotes and run the following command in terminal):
58+
Manual Setup (set values in double quotes and run the following commands in terminal):
4359
```shell
4460
export AWS_ACCOUNT_ID="" ## e.g. 123456789012
4561
export AWS_DEFAULT_REGION="" ## e.g. us-east-1
@@ -59,7 +75,12 @@ Automated Setup (run the following command in terminal):
5975
export AWS_DEFAULT_REGION="$(aws configure get region --output=text)"
6076
```
6177

62-
## Create Terraform Configurations Using TerraHub
78+
## Terraform Automation and Orchestration Tool
79+
80+
The next couple of paragraphs are show casing the process of creating terraform
81+
configurations using [TerraHub CLI](https://github.com/TerraHubCorp/terrahub).
82+
We have opted to use YML format instead of HCL because it's easier and faster
83+
to customize and automate terraform runs (see `terrahub component` command).
6384

6485
Run the following commands in terminal:
6586
```shell
@@ -76,6 +97,8 @@ [email protected] (built: 2018-04-07T19:15:39.787Z)
7697
> NOTE: If you don't have TerraHub CLI, check out
7798
[installation guide](https://www.npmjs.com/package/terrahub)
7899

100+
## Build Terraform Configurations
101+
79102
Run the following commands in terminal:
80103
```shell
81104
mkdir demo-terraform-automation-aws
@@ -88,6 +111,12 @@ Your output should be similar to the one below:
88111
✅ Project successfully initialized
89112
```
90113

114+
> NOTE: If you want to jump directly to terraform automation part of the demo,
115+
instead of creating `demo-terraform-automation-aws` from scratch, clone current
116+
repository, follow the instructions for `Update Project Config` and skip down to
117+
`Visualize TerraHub Components`. This way you will fast forward through terrahub
118+
components creation and customization, and switch directly to the automation part.
119+
91120
## Create TerraHub Components from Templates
92121

93122
Run the following command in terminal:
@@ -108,13 +137,13 @@ Your output should be similar to the one below:
108137

109138
## Update Project Config
110139

111-
Run the following command in terminal:
140+
Run the following commands in terminal:
112141
```shell
113142
terrahub configure -c terraform.version=0.11.11
114143
terrahub configure -c template.provider.aws.region='${local.region}'
115144
terrahub configure -c template.provider.aws.allowed_account_ids[0]='${local.account_id}'
116-
terrahub configure -c template.locals.account_id="${AWS_ACCOUNT_ID}"
117145
terrahub configure -c template.locals.region="${AWS_DEFAULT_REGION}"
146+
terrahub configure -c template.locals.account_id="${AWS_ACCOUNT_ID}"
118147
```
119148

120149
Your output should be similar to the one below:
@@ -124,7 +153,7 @@ Your output should be similar to the one below:
124153

125154
## Customize TerraHub Component for VPC
126155

127-
Run the following command in terminal:
156+
Run the following commands in terminal:
128157
```shell
129158
terrahub configure -i vpc -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/vpc/terraform.tfstate'
130159
terrahub configure -i vpc -c component.template.resource.aws_vpc.vpc.assign_generated_ipv6_cidr_block='true'
@@ -145,7 +174,7 @@ Your output should be similar to the one below:
145174

146175
## Customize TerraHub Component for Subnet
147176

148-
Run the following command in terminal:
177+
Run the following commands in terminal:
149178
```shell
150179
terrahub configure -i subnet_private -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/subnet_private/terraform.tfstate'
151180
terrahub configure -i subnet_private -c component.template.data.aws_availability_zones.az={}
@@ -174,7 +203,7 @@ Your output should be similar to the one below:
174203

175204
## Customize TerraHub Component for Security Group
176205

177-
Run the following command in terminal:
206+
Run the following commands in terminal:
178207
```shell
179208
terrahub configure -i security_group -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/security_group/terraform.tfstate'
180209
terrahub configure -i security_group -c component.template.data.terraform_remote_state.vpc.backend='local'
@@ -194,7 +223,7 @@ Your output should be similar to the one below:
194223

195224
## Customize TerraHub Component for IAM Role
196225

197-
Run the following command in terminal:
226+
Run the following commands in terminal:
198227
```shell
199228
terrahub configure -i iam_role -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/iam_role/terraform.tfstate'
200229
terrahub configure -i iam_role -c component.template.data.template_file.iam_role_policy.template='${file("${local.project["path"]}/iam_assume_policy.json.tpl")}'
@@ -217,7 +246,7 @@ Your output should be similar to the one below:
217246

218247
## Customize TerraHub Component for Lambda
219248

220-
Run the following command in terminal:
249+
Run the following commands in terminal:
221250
```shell
222251
terrahub configure -i lambda -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/lambda/terraform.tfstate'
223252
terrahub configure -i lambda -c component.template.data.terraform_remote_state.iam.backend='local'
@@ -256,7 +285,7 @@ Your output should be similar to the one below:
256285

257286
## Customize TerraHub Component for API Gateway RestAPI
258287

259-
Run the following command in terminal:
288+
Run the following commands in terminal:
260289
```shell
261290
terrahub configure -i api_gateway_rest_api -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/api_gateway_rest_api/terraform.tfstate'
262291
terrahub configure -i api_gateway_rest_api -c component.template.data.template_file.swagger.template='${file("${local.project["path"]}/api_swagger.json.tpl")}'
@@ -274,7 +303,7 @@ Your output should be similar to the one below:
274303

275304
## Customize TerraHub Component for API Gateway Deployment
276305

277-
Run the following command in terminal:
306+
Run the following commands in terminal:
278307
```shell
279308
terrahub configure -i api_gateway_deployment -c component.template.terraform.backend.local.path='/tmp/.terrahub/local_backend/api_gateway_deployment/terraform.tfstate'
280309
terrahub configure -i api_gateway_deployment -c component.template.data.aws_api_gateway_rest_api.api_gateway_deployment.name='DemoApi7356626c'
@@ -312,15 +341,33 @@ Project: demo-terraform-automation-aws
312341

313342
## Run TerraHub Automation
314343

344+
### Prepare Source Code for Deployment
345+
315346
Run the following command in terminal:
347+
316348
```shell
317349
terrahub build -i lambda
318-
terrahub run -a -y
319350
```
320351

321-
## Run Test Command
352+
Your output should be similar to the one below:
353+
```
354+
```
355+
356+
### Run TerraHub Automation
322357

323358
Run the following command in terminal:
359+
360+
```shell
361+
terrahub run -y -a
362+
```
363+
364+
Your output should be similar to the one below:
365+
```
366+
```
367+
368+
## Testing Deployed Cloud Resources
369+
370+
Check if backend was deployed successfully. Run the following command in terminal:
324371
```
325372
curl https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/demo
326373
```

0 commit comments

Comments
 (0)