Skip to content

Commit 5ac1f1a

Browse files
d4kvermaanmolnagpal13archit
authored
new Argument Reference added with multi ebs option (#53)
* fix: new Argument Reference added with multi ebs option * tf check githb action fixed * tf check githb action fixed * tf check github action fixed * tf check git action for subnet id * feat: default insance key-pair option added * feat: default insance key-pair option added * fix: Added enable variable and updated example folder heirarchy * fix: Removed public key from example --------- Co-authored-by: Anmol Nagpal <[email protected]> Co-authored-by: Archit Chopra <[email protected]>
1 parent 01ab087 commit 5ac1f1a

File tree

17 files changed

+498
-369
lines changed

17 files changed

+498
-369
lines changed

.github/dependabot.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@
55

66
version: 2
77
updates:
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "daily"
13+
open-pull-requests-limit: 3
14+
assignees:
15+
- "clouddrove-ci"
16+
reviewers:
17+
- "approvers"
18+
819
- package-ecosystem: "terraform" # See documentation for possible values
9-
directory: "/" # Location of package manifests
20+
directory: "_example/basic" # Location of package manifests
1021
schedule:
1122
interval: "weekly"
1223
# Add assignees
@@ -16,7 +27,7 @@ updates:
1627
reviewers:
1728
- "approvers"
1829
- package-ecosystem: "terraform" # See documentation for possible values
19-
directory: "_example/basic_example" # Location of package manifests
30+
directory: "_example/complete" # Location of package manifests
2031
schedule:
2132
interval: "weekly"
2233
# Add assignees
@@ -26,7 +37,7 @@ updates:
2637
reviewers:
2738
- "approvers"
2839
- package-ecosystem: "terraform" # See documentation for possible values
29-
directory: "_example/ebs_mount" # Location of package manifests
40+
directory: "_example/spot_instance" # Location of package manifests
3041
schedule:
3142
interval: "weekly"
3243
# Add assignees

.github/workflows/tf-checks.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88
basic_example:
99
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
1010
with:
11-
working_directory: './_example/basic_example/'
12-
ebs_mount:
11+
working_directory: './_example/basic/'
12+
complete_example:
1313
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
1414
with:
15-
working_directory: './_example/ebs_mount/'
15+
working_directory: './_example/complete/'
1616
spot_instance:
1717
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
1818
with:

README.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# This is the canonical configuration for the `README.md`
44
# Run `make readme` to rebuild the `README.md`
5-
#
65

76
# Name of this project
87
name: Terraform AWS EC2
@@ -25,6 +24,10 @@ badges:
2524
image: "https://img.shields.io/badge/License-APACHE-blue.svg"
2625
url: "LICENSE.md"
2726

27+
prerequesties:
28+
- name: Terraform 1.4.6
29+
url: https://learn.hashicorp.com/terraform/getting-started/install.html
30+
2831
# description of this project
2932
description: |-
3033
Terraform module to create an EC2 resource on AWS with ElasticC IP Addresses and Elastic Block Store.

_example/basic/example.tf

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
##----------------------------------------------------------------------------------
2+
## Terraform module to create instance module on AWS.
3+
##----------------------------------------------------------------------------------
4+
module "ec2" {
5+
source = "./../../"
6+
name = "ec2"
7+
environment = "test"
8+
9+
##----------------------------------------------------------------------------------
10+
## Below A security group controls the traffic that is allowed to reach and leave the resources that it is associated with.
11+
##----------------------------------------------------------------------------------
12+
#tfsec:aws-ec2-no-public-ingress-sgr
13+
vpc_id = "vpc-xxxxxxxxx"
14+
ssh_allowed_ip = ["0.0.0.0/0"]
15+
ssh_allowed_ports = [22]
16+
17+
#instance
18+
instance_count = 1
19+
ami = "ami-08d658f84a6d84a80"
20+
instance_type = "c4.xlarge"
21+
22+
#Networking
23+
subnet_ids = ["subnet-xxxxxxxx"]
24+
25+
#Keypair
26+
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCm63Yf1+E6Fkts7LcAdOalvdUrZE0oA1A6pJUkx9c/V8ZFuclg7uNdnXV98iHWlA6tcvV69HsdBJZU3w66+6rxGgM0dbwSalRz60IGM40HwRTYZNn0e/1xwL3O0tvsIiSdapLDjPXIm4zZGQL7KXT98f6LJzDfDBF67ZEAVoeOxIl/a1k+DOTRuFtg7dtvPhJQpDCh685EtiC/+HH4vpHcw3LcNfP2WaifQpCG4Pxgj6KWf1bGVJhhpN26lbJYfN4n+GZJYDKDS+Tc4eF4aC1s1JnOtKC2z1bb+FI7Y4ZdYfIsdf0P1Fo751JLp7fjTqckBgxYd+iXAhKO6dPjbVp3L56pxTJbbSgi5Cw29+Ef8AcK9WOGCgbnma7XmCpFF0NxSSLim74p2y+oyjt1UmX9UvOKnb1MXlGW4JYo4qQV4M5TL64JcYa5sSRDvMhtpC83YVpKyRb3bTNZySsgkDuxFCNsJ0c9UAWTbqzSmhpPsM9ItfBSxhq0oiogGpvNgXM="
27+
28+
#IAM
29+
iam_instance_profile = "iam-profile-xxxxxxxxx"
30+
31+
#Root Volume
32+
root_block_device = [
33+
{
34+
volume_type = "gp2"
35+
volume_size = 15
36+
delete_on_termination = true
37+
}
38+
]
39+
#Tags
40+
instance_tags = { "snapshot" = true }
41+
42+
}
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Terraform version
22
terraform {
3-
required_version = ">= 1.5.0"
3+
required_version = ">= 1.5.5"
44

55
required_providers {
66
aws = {
77
source = "hashicorp/aws"
8-
version = ">= 5.9.0"
8+
version = ">= 5.13.1"
99
}
1010
}
1111
}

_example/basic_example/main.tf

-126
This file was deleted.

_example/ebs_mount/main.tf _example/complete/example.tf

+28-31
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,32 @@ provider "aws" {
55
region = "eu-west-1"
66
}
77

8+
locals {
9+
environment = "test-app"
10+
label_order = ["name", "environment"]
11+
}
12+
813
####----------------------------------------------------------------------------------
914
## A VPC is a virtual network that closely resembles a traditional network that you'd operate in your own data center.
1015
####----------------------------------------------------------------------------------
1116
module "vpc" {
12-
source = "clouddrove/vpc/aws"
13-
version = "2.0.0"
14-
17+
source = "clouddrove/vpc/aws"
18+
version = "2.0.0"
1519
name = "vpc"
16-
environment = "test"
17-
label_order = ["name", "environment"]
18-
19-
cidr_block = "172.16.0.0/16"
20+
environment = local.environment
21+
label_order = local.label_order
22+
cidr_block = "172.16.0.0/16"
2023
}
2124

2225
####----------------------------------------------------------------------------------
2326
## A subnet is a range of IP addresses in your VPC.
2427
####----------------------------------------------------------------------------------
2528
module "public_subnets" {
26-
source = "clouddrove/subnet/aws"
27-
version = "2.0.0"
28-
29-
name = "public-subnet"
30-
environment = "test"
31-
label_order = ["name", "environment"]
32-
29+
source = "clouddrove/subnet/aws"
30+
version = "2.0.0"
31+
name = "public-subnet"
32+
environment = local.environment
33+
label_order = local.label_order
3334
availability_zones = ["eu-west-1b", "eu-west-1c"]
3435
vpc_id = module.vpc.vpc_id
3536
cidr_block = module.vpc.vpc_cidr_block
@@ -39,16 +40,14 @@ module "public_subnets" {
3940
}
4041

4142
module "iam-role" {
42-
source = "clouddrove/iam-role/aws"
43-
version = "1.3.0"
44-
43+
source = "clouddrove/iam-role/aws"
44+
version = "1.3.0"
4545
name = "iam-role"
46-
environment = "test"
47-
label_order = ["name", "environment"]
46+
environment = local.environment
47+
label_order = local.label_order
4848
assume_role_policy = data.aws_iam_policy_document.default.json
49-
50-
policy_enabled = true
51-
policy = data.aws_iam_policy_document.iam-policy.json
49+
policy_enabled = true
50+
policy = data.aws_iam_policy_document.iam-policy.json
5251
}
5352

5453
data "aws_iam_policy_document" "default" {
@@ -75,30 +74,28 @@ data "aws_iam_policy_document" "iam-policy" {
7574
}
7675
}
7776

78-
####----------------------------------------------------------------------------------
77+
##----------------------------------------------------------------------------------
7978
## Terraform module to create ec2 instance module on AWS.
80-
####----------------------------------------------------------------------------------
79+
##----------------------------------------------------------------------------------
8180
module "ec2" {
8281
source = "./../../"
8382
name = "ec2"
84-
environment = "test"
85-
label_order = ["name", "environment"]
83+
environment = local.environment
8684

87-
####----------------------------------------------------------------------------------
85+
##----------------------------------------------------------------------------------
8886
## Below A security group controls the traffic that is allowed to reach and leave the resources that it is associated with.
89-
####----------------------------------------------------------------------------------
87+
##----------------------------------------------------------------------------------
9088
#tfsec:aws-ec2-no-public-ingress-sgr
9189
vpc_id = module.vpc.vpc_id
9290
ssh_allowed_ip = ["0.0.0.0/0"]
9391
ssh_allowed_ports = [22]
94-
9592
#Instance
9693
instance_count = 1
9794
ami = "ami-08d658f84a6d84a80"
9895
instance_type = "t2.nano"
9996

10097
#Keypair
101-
public_key = "HEOM3+lajUSGqWk3Bw/NgygEf1Kgw7gyK3jsTVVcokhK3TDuR3pi4u2QDR2tvLXddPKd37a2S7rjeqecw+XRW9559zKaR7RJJfjO1u1Onc2tgA3y0btdju2bcYBtFkRVOLwpog8CvslYEDLmdVBIlCOnJDkwHK71lKihGKdkeXEtAj0aOQzAJsIpDFXz7vob9OiA/fb2T3t4R1EwEsPEnYVczKMsqUyqa+EE36bItcZHQyCPVN7+bRJyJpPcrfrsAa4yMtiHUUiecPdL/6HYwGHxA5rUX3uD2UBm6sbGBH00ZCj6yUxl2UQR5NE4NR35NI86Q+q1kNOc5VctxxQOTHBwKHaGvKLk4c5gHXaEl8yyYL0wVkL00KYx3GCh1"
98+
public_key = ""
10299

103100
#Networking
104101
subnet_ids = tolist(module.public_subnets.public_subnet_id)
@@ -125,4 +122,4 @@ module "ec2" {
125122

126123
#Mount EBS With User Data
127124
user_data = file("user-data.sh")
128-
}
125+
}
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Terraform version
22
terraform {
3-
required_version = ">= 1.5.0"
3+
required_version = ">= 1.5.5"
44

55
required_providers {
66
aws = {
77
source = "hashicorp/aws"
8-
version = ">= 5.9.0"
8+
version = ">= 5.13.1"
99
}
1010
}
1111
}

0 commit comments

Comments
 (0)