Skip to content

Commit

Permalink
new Argument Reference added with multi ebs option (#53)
Browse files Browse the repository at this point in the history
* 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 <anmol@clouddrove.com>
Co-authored-by: Archit Chopra <chopra13archit@gmail.com>
  • Loading branch information
3 people committed Aug 28, 2023
1 parent 01ab087 commit 5ac1f1a
Show file tree
Hide file tree
Showing 17 changed files with 498 additions and 369 deletions.
17 changes: 14 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 3
assignees:
- "clouddrove-ci"
reviewers:
- "approvers"

- package-ecosystem: "terraform" # See documentation for possible values
directory: "/" # Location of package manifests
directory: "_example/basic" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
Expand All @@ -16,7 +27,7 @@ updates:
reviewers:
- "approvers"
- package-ecosystem: "terraform" # See documentation for possible values
directory: "_example/basic_example" # Location of package manifests
directory: "_example/complete" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
Expand All @@ -26,7 +37,7 @@ updates:
reviewers:
- "approvers"
- package-ecosystem: "terraform" # See documentation for possible values
directory: "_example/ebs_mount" # Location of package manifests
directory: "_example/spot_instance" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tf-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
basic_example:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
with:
working_directory: './_example/basic_example/'
ebs_mount:
working_directory: './_example/basic/'
complete_example:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
with:
working_directory: './_example/ebs_mount/'
working_directory: './_example/complete/'
spot_instance:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
with:
Expand Down
5 changes: 4 additions & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#

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

prerequesties:
- name: Terraform 1.4.6
url: https://learn.hashicorp.com/terraform/getting-started/install.html

# description of this project
description: |-
Terraform module to create an EC2 resource on AWS with ElasticC IP Addresses and Elastic Block Store.
Expand Down
42 changes: 42 additions & 0 deletions _example/basic/example.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##----------------------------------------------------------------------------------
## Terraform module to create instance module on AWS.
##----------------------------------------------------------------------------------
module "ec2" {
source = "./../../"
name = "ec2"
environment = "test"

##----------------------------------------------------------------------------------
## Below A security group controls the traffic that is allowed to reach and leave the resources that it is associated with.
##----------------------------------------------------------------------------------
#tfsec:aws-ec2-no-public-ingress-sgr
vpc_id = "vpc-xxxxxxxxx"
ssh_allowed_ip = ["0.0.0.0/0"]
ssh_allowed_ports = [22]

#instance
instance_count = 1
ami = "ami-08d658f84a6d84a80"
instance_type = "c4.xlarge"

#Networking
subnet_ids = ["subnet-xxxxxxxx"]

#Keypair
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCm63Yf1+E6Fkts7LcAdOalvdUrZE0oA1A6pJUkx9c/V8ZFuclg7uNdnXV98iHWlA6tcvV69HsdBJZU3w66+6rxGgM0dbwSalRz60IGM40HwRTYZNn0e/1xwL3O0tvsIiSdapLDjPXIm4zZGQL7KXT98f6LJzDfDBF67ZEAVoeOxIl/a1k+DOTRuFtg7dtvPhJQpDCh685EtiC/+HH4vpHcw3LcNfP2WaifQpCG4Pxgj6KWf1bGVJhhpN26lbJYfN4n+GZJYDKDS+Tc4eF4aC1s1JnOtKC2z1bb+FI7Y4ZdYfIsdf0P1Fo751JLp7fjTqckBgxYd+iXAhKO6dPjbVp3L56pxTJbbSgi5Cw29+Ef8AcK9WOGCgbnma7XmCpFF0NxSSLim74p2y+oyjt1UmX9UvOKnb1MXlGW4JYo4qQV4M5TL64JcYa5sSRDvMhtpC83YVpKyRb3bTNZySsgkDuxFCNsJ0c9UAWTbqzSmhpPsM9ItfBSxhq0oiogGpvNgXM="

#IAM
iam_instance_profile = "iam-profile-xxxxxxxxx"

#Root Volume
root_block_device = [
{
volume_type = "gp2"
volume_size = 15
delete_on_termination = true
}
]
#Tags
instance_tags = { "snapshot" = true }

}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.0"
required_version = ">= 1.5.5"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.9.0"
version = ">= 5.13.1"
}
}
}
126 changes: 0 additions & 126 deletions _example/basic_example/main.tf

This file was deleted.

59 changes: 28 additions & 31 deletions _example/ebs_mount/main.tf → _example/complete/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,32 @@ provider "aws" {
region = "eu-west-1"
}

locals {
environment = "test-app"
label_order = ["name", "environment"]
}

####----------------------------------------------------------------------------------
## A VPC is a virtual network that closely resembles a traditional network that you'd operate in your own data center.
####----------------------------------------------------------------------------------
module "vpc" {
source = "clouddrove/vpc/aws"
version = "2.0.0"

source = "clouddrove/vpc/aws"
version = "2.0.0"
name = "vpc"
environment = "test"
label_order = ["name", "environment"]

cidr_block = "172.16.0.0/16"
environment = local.environment
label_order = local.label_order
cidr_block = "172.16.0.0/16"
}

####----------------------------------------------------------------------------------
## A subnet is a range of IP addresses in your VPC.
####----------------------------------------------------------------------------------
module "public_subnets" {
source = "clouddrove/subnet/aws"
version = "2.0.0"

name = "public-subnet"
environment = "test"
label_order = ["name", "environment"]

source = "clouddrove/subnet/aws"
version = "2.0.0"
name = "public-subnet"
environment = local.environment
label_order = local.label_order
availability_zones = ["eu-west-1b", "eu-west-1c"]
vpc_id = module.vpc.vpc_id
cidr_block = module.vpc.vpc_cidr_block
Expand All @@ -39,16 +40,14 @@ module "public_subnets" {
}

module "iam-role" {
source = "clouddrove/iam-role/aws"
version = "1.3.0"

source = "clouddrove/iam-role/aws"
version = "1.3.0"
name = "iam-role"
environment = "test"
label_order = ["name", "environment"]
environment = local.environment
label_order = local.label_order
assume_role_policy = data.aws_iam_policy_document.default.json

policy_enabled = true
policy = data.aws_iam_policy_document.iam-policy.json
policy_enabled = true
policy = data.aws_iam_policy_document.iam-policy.json
}

data "aws_iam_policy_document" "default" {
Expand All @@ -75,30 +74,28 @@ data "aws_iam_policy_document" "iam-policy" {
}
}

####----------------------------------------------------------------------------------
##----------------------------------------------------------------------------------
## Terraform module to create ec2 instance module on AWS.
####----------------------------------------------------------------------------------
##----------------------------------------------------------------------------------
module "ec2" {
source = "./../../"
name = "ec2"
environment = "test"
label_order = ["name", "environment"]
environment = local.environment

####----------------------------------------------------------------------------------
##----------------------------------------------------------------------------------
## Below A security group controls the traffic that is allowed to reach and leave the resources that it is associated with.
####----------------------------------------------------------------------------------
##----------------------------------------------------------------------------------
#tfsec:aws-ec2-no-public-ingress-sgr
vpc_id = module.vpc.vpc_id
ssh_allowed_ip = ["0.0.0.0/0"]
ssh_allowed_ports = [22]

#Instance
instance_count = 1
ami = "ami-08d658f84a6d84a80"
instance_type = "t2.nano"

#Keypair
public_key = "HEOM3+lajUSGqWk3Bw/NgygEf1Kgw7gyK3jsTVVcokhK3TDuR3pi4u2QDR2tvLXddPKd37a2S7rjeqecw+XRW9559zKaR7RJJfjO1u1Onc2tgA3y0btdju2bcYBtFkRVOLwpog8CvslYEDLmdVBIlCOnJDkwHK71lKihGKdkeXEtAj0aOQzAJsIpDFXz7vob9OiA/fb2T3t4R1EwEsPEnYVczKMsqUyqa+EE36bItcZHQyCPVN7+bRJyJpPcrfrsAa4yMtiHUUiecPdL/6HYwGHxA5rUX3uD2UBm6sbGBH00ZCj6yUxl2UQR5NE4NR35NI86Q+q1kNOc5VctxxQOTHBwKHaGvKLk4c5gHXaEl8yyYL0wVkL00KYx3GCh1"
public_key = ""

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

#Mount EBS With User Data
user_data = file("user-data.sh")
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.0"
required_version = ">= 1.5.5"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.9.0"
version = ">= 5.13.1"
}
}
}
Loading

0 comments on commit 5ac1f1a

Please sign in to comment.