Skip to content

Commit 71ae239

Browse files
author
Nikita Dugar
authored
Merge pull request #19 from clouddrove/0.15
update in 0.15
2 parents e9e99f0 + 56757ac commit 71ae239

16 files changed

+280
-114
lines changed

.github/workflows/terraform.yml

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,105 @@ on:
55
- master
66

77
jobs:
8-
terraform:
9-
name: 'Terraform'
8+
fmt:
9+
name: 'terraform fmt'
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: 'Checkout'
13-
uses: actions/checkout@master
13+
uses: actions/checkout@v2.3.4
1414

15-
- name: Configure AWS Credentials
15+
- name: 'Terraform Format'
16+
uses: 'clouddrove/[email protected]'
17+
with:
18+
actions_subcommand: 'fmt'
19+
- name: 'Terraform Format'
20+
uses: 'clouddrove/[email protected]'
21+
with:
22+
actions_subcommand: 'fmt'
23+
24+
basic_example:
25+
name: 'basic_example'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: 'Checkout'
29+
uses: actions/[email protected]
30+
31+
- name: 'Configure AWS Credentials'
1632
uses: clouddrove/configure-aws-credentials@v1
1733
with:
1834
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
1935
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
2036
aws-region: us-east-2
2137

22-
- name: 'Terraform Format'
23-
uses: 'clouddrove/[email protected]'
24-
with:
25-
actions_subcommand: 'fmt'
26-
27-
- name: 'Terraform init Basic'
28-
uses: 'clouddrove/[email protected]'
38+
- name: 'Terraform init'
39+
uses: 'clouddrove/[email protected]'
2940
with:
3041
actions_subcommand: 'init'
3142
tf_actions_working_dir: ./_example/basic_example
3243

33-
- name: 'Terraform validate Basic'
34-
uses: 'clouddrove/github-actions@v6.0'
44+
- name: 'Terraform validate'
45+
uses: 'clouddrove/github-actions@v7.0'
3546
with:
3647
actions_subcommand: 'validate'
3748
tf_actions_working_dir: ./_example/basic_example
3849

39-
- name: 'Terraform plan Basic'
40-
uses: 'clouddrove/github-actions@v6.0'
50+
- name: 'Terraform plan for basic_example'
51+
uses: 'clouddrove/github-actions@v7.0'
4152
with:
4253
actions_subcommand: 'plan'
4354
tf_actions_working_dir: ./_example/basic_example
4455

45-
- name: 'Terraform init Secure'
46-
uses: 'clouddrove/[email protected]'
56+
secure_example:
57+
name: 'secure_example'
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: 'Checkout'
61+
uses: actions/[email protected]
62+
63+
- name: 'Configure AWS Credentials'
64+
uses: clouddrove/configure-aws-credentials@v1
65+
with:
66+
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
67+
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
68+
aws-region: us-east-2
69+
70+
- name: 'Terraform init'
71+
uses: 'clouddrove/[email protected]'
4772
with:
4873
actions_subcommand: 'init'
4974
tf_actions_working_dir: ./_example/secure_example
5075

51-
- name: 'Terraform validate Secure'
52-
uses: 'clouddrove/github-actions@v6.0'
76+
- name: 'Terraform validate'
77+
uses: 'clouddrove/github-actions@v7.0'
5378
with:
5479
actions_subcommand: 'validate'
5580
tf_actions_working_dir: ./_example/secure_example
5681

57-
- name: 'Terraform plan Secure'
58-
uses: 'clouddrove/github-actions@v6.0'
82+
- name: 'Terraform plan for secure_example'
83+
uses: 'clouddrove/github-actions@v7.0'
5984
with:
6085
actions_subcommand: 'plan'
6186
tf_actions_working_dir: ./_example/secure_example
6287

88+
pre-commit:
89+
name: 'Pre-Commit'
90+
needs:
91+
- fmt
92+
- basic_example
93+
- secure_example
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: 'Checkout'
97+
uses: actions/[email protected]
98+
99+
- name: 'Install Tflint'
100+
run: |
101+
curl https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
102+
103+
- name: 'Pre-Commit 🔎'
104+
uses: pre-commit/[email protected]
105+
continue-on-error: true
106+
63107
- name: 'Slack Notification'
64108
uses: clouddrove/action-slack@v2
65109
with:
@@ -69,4 +113,4 @@ jobs:
69113
env:
70114
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
71115
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
72-
if: always()
116+
if: always()

.github/workflows/terratest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ jobs:
4848
env:
4949
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
5050
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
51-
if: always()
51+
if: always()

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
*.iml
77
go.sum
88
*.terraform.lock.hcl
9-
crash.log
9+
crash.log

.pre-commit-config.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
repos:
2-
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.45.0
2+
3+
- repo: https://github.com/gruntwork-io/pre-commit
4+
rev: v0.1.12 # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
45
hooks:
5-
- id: terraform_fmt
6+
- id: terraform-fmt
7+
- id: shellcheck
8+
- id: tflint
69

7-
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v3.4.0
10+
- repo: git://github.com/pre-commit/pre-commit-hooks
11+
rev: v4.0.1 # Use the ref you want to point at
912
hooks:
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace
15+
- id: mixed-line-ending
16+
- id: check-byte-order-marker
17+
- id: check-executables-have-shebangs
1018
- id: check-merge-conflict
19+
- id: debug-statements
1120
- id: check-yaml
1221
- id: check-added-large-files
13-
- id: trailing-whitespace

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export GENIE_PATH ?= $(shell 'pwd')/../../../genie
22

3-
include $(GENIE_PATH)/Makefile
3+
include $(GENIE_PATH)/Makefile

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Terraform AWS EC2
88
</h1>
99

10-
<p align="center" style="font-size: 1.2rem;">
10+
<p align="center" style="font-size: 1.2rem;">
1111
Terraform module to create an EC2 resource on AWS with ElasticC IP Addresses and Elastic Block Store.
1212
</p>
1313

@@ -38,7 +38,7 @@
3838
<hr>
3939

4040

41-
We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
41+
We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
4242

4343
This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
4444

@@ -49,7 +49,7 @@ We have [*fifty plus terraform modules*][terraform_modules]. A few of them are c
4949

5050
## Prerequisites
5151

52-
This module has a few dependencies:
52+
This module has a few dependencies:
5353

5454
- [Terraform 0.13](https://learn.hashicorp.com/terraform/getting-started/install.html)
5555
- [Go](https://golang.org/doc/install)
@@ -212,7 +212,7 @@ Here is examples of how you can use this module in your inventory structure:
212212

213213

214214
## Testing
215-
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.
215+
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.
216216

217217
You need to run the following command in the testing folder:
218218
```hcl
@@ -221,7 +221,7 @@ You need to run the following command in the testing folder:
221221

222222

223223

224-
## Feedback
224+
## Feedback
225225
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-ec2/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).
226226

227227
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-aws-ec2)!

README.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ github_repo: clouddrove/terraform-aws-ec2
1616
# Badges to display
1717
badges:
1818
- name: "Terraform"
19-
image: "https://img.shields.io/badge/Terraform-v0.14-green"
19+
image: "https://img.shields.io/badge/Terraform-v0.15-green"
2020
url: "https://www.terraform.io"
2121
- name: "Licence"
2222
image: "https://img.shields.io/badge/License-MIT-blue.svg"
@@ -39,8 +39,7 @@ usage: |-
3939
```hcl
4040
module "ec2" {
4141
source = "clouddrove/ec2/aws"
42-
version = "0.14.0"
43-
repository = "https://registry.terraform.io/modules/clouddrove/ec2/aws/0.14.0"
42+
version = "0.15.0"
4443
environment = "test"
4544
label_order = ["name", "environment"]
4645
instance_count = 2
@@ -69,8 +68,7 @@ usage: |-
6968
```hcl
7069
module "ec2" {
7170
source = "clouddrove/ec2/aws"
72-
version = "0.14.0"
73-
repository = "https://registry.terraform.io/modules/clouddrove/ec2/aws/0.14.0"
71+
version = "0.15.0"
7472
environment = "test"
7573
label_order = ["name", "environment"]
7674
instance_count = 2

_example/basic_example/example.tf

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ provider "aws" {
44

55
module "vpc" {
66
source = "clouddrove/vpc/aws"
7-
version = "0.14.0"
7+
version = "0.15.0"
88

99
name = "vpc"
10-
repository = "https://registry.terraform.io/modules/clouddrove/vpc/aws/0.14.0"
1110
environment = "test"
1211
label_order = ["name", "environment"]
1312

@@ -16,10 +15,9 @@ module "vpc" {
1615

1716
module "public_subnets" {
1817
source = "clouddrove/subnet/aws"
19-
version = "0.14.0"
18+
version = "0.15.0"
2019

2120
name = "public-subnet"
22-
repository = "https://registry.terraform.io/modules/clouddrove/subnet/aws/0.14.0"
2321
environment = "test"
2422
label_order = ["name", "environment"]
2523

@@ -33,9 +31,8 @@ module "public_subnets" {
3331

3432
module "http-https" {
3533
source = "clouddrove/security-group/aws"
36-
version = "0.14.0"
34+
version = "0.15.0"
3735
name = "http-https"
38-
repository = "https://registry.terraform.io/modules/security-group/ec2/aws/0.14.0"
3936
environment = "test"
4037
label_order = ["name", "environment"]
4138

@@ -46,9 +43,8 @@ module "http-https" {
4643

4744
module "ssh" {
4845
source = "clouddrove/security-group/aws"
49-
version = "0.14.0"
46+
version = "0.15.0"
5047
name = "ssh"
51-
repository = "https://registry.terraform.io/modules/clouddrove/security-group/aws/0.14.0"
5248
environment = "test"
5349
label_order = ["name", "environment"]
5450

@@ -59,10 +55,9 @@ module "ssh" {
5955

6056
module "iam-role" {
6157
source = "clouddrove/iam-role/aws"
62-
version = "0.14.0"
58+
version = "0.15.0"
6359

6460
name = "iam-role"
65-
repository = "https://registry.terraform.io/modules/clouddrove/iam-role/aws/0.14.0"
6661
environment = "test"
6762
label_order = ["name", "environment"]
6863
assume_role_policy = data.aws_iam_policy_document.default.json
@@ -73,7 +68,7 @@ module "iam-role" {
7368

7469
module "kms_key" {
7570
source = "clouddrove/kms/aws"
76-
version = "0.14.0"
71+
version = "0.15.0"
7772
name = "kms"
7873
environment = "test"
7974
label_order = ["environment", "name"]
@@ -125,12 +120,10 @@ data "aws_iam_policy_document" "iam-policy" {
125120
}
126121
}
127122

128-
129123
module "ec2" {
130124
source = "./../../"
131125

132126
name = "ec2-instance"
133-
repository = "https://registry.terraform.io/modules/clouddrove/ec2/aws/0.14.0"
134127
environment = "test"
135128
label_order = ["name", "environment"]
136129

@@ -142,20 +135,23 @@ module "ec2" {
142135
vpc_security_group_ids_list = [module.ssh.security_group_ids, module.http-https.security_group_ids]
143136
subnet_ids = tolist(module.public_subnets.public_subnet_id)
144137

145-
assign_eip_address = true
146-
associate_public_ip_address = true
147-
148-
instance_profile_enabled = true
149-
iam_instance_profile = module.iam-role.name
138+
assign_eip_address = true
139+
associate_public_ip_address = true
140+
instance_profile_enabled = true
141+
iam_instance_profile = module.iam-role.name
142+
disk_size = 8
143+
ebs_optimized = false
144+
ebs_volume_enabled = true
145+
ebs_volume_type = "gp2"
146+
ebs_volume_size = 30
147+
instance_tags = { "snapshot" = true }
148+
dns_zone_id = "Z1XJD7SSBKXLC1"
149+
hostname = "ec2"
150+
kms_key_id = module.kms_key.key_arn
151+
metadata_http_tokens_required = true
152+
metadata_http_endpoint_enabled = true
153+
metadata_http_put_response_hop_limit = "2"
154+
delete_on_termination = false
155+
user_data = file("user-data.sh")
150156

151-
disk_size = 8
152-
ebs_optimized = false
153-
ebs_volume_enabled = true
154-
ebs_volume_type = "gp2"
155-
ebs_volume_size = 30
156-
157-
instance_tags = { "snapshot" = true }
158-
dns_zone_id = "Z1XJD7SSBKXLC1"
159-
hostname = "ec2"
160-
kms_key_id = module.kms_key.key_arn
161-
}
157+
}

_example/basic_example/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
output "instance_id" {
22
value = module.ec2.*.instance_id
33
description = "The instance ID."
4-
}
4+
}

0 commit comments

Comments
 (0)