Skip to content

Version v1 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9b0f250
changed the aws AMI id
Jul 20, 2022
e5e820c
Update c1-versions.tf
hemanthhp1229 Jul 26, 2022
0594a0c
added the missing braces
Jul 27, 2022
7bd8af1
added the missing braces
Jul 27, 2022
fddf333
Update c2-variables.tf
hemanthhp1229 Jul 27, 2022
e53ca3a
Update c3-ec2securitygroups.tf
hemanthhp1229 Jul 27, 2022
4bc2c60
Update c4-ami-datasource.tf
hemanthhp1229 Jul 27, 2022
a496910
Update c5-ec2instance.tf
hemanthhp1229 Jul 27, 2022
159012d
Update c6-outputs.tf
hemanthhp1229 Jul 27, 2022
2b25f61
Update c1-versions.tf
hemanthhp1229 Jul 27, 2022
9081eda
changed the regex name
Jul 27, 2022
4c819d5
Add files via upload
hemanthhp1229 Jul 27, 2022
6afdffa
Delete terraform-key.pem
hemanthhp1229 Jul 27, 2022
f0f42ad
adding my changes and changed the private key
hemanthhp1229 Aug 6, 2022
c3ce00a
updated the output block
hemanthhp1229 Aug 6, 2022
5a65c99
updated terraform version
hemanthhp1229 Aug 6, 2022
8b9ee11
updated the output block names
hemanthhp1229 Aug 6, 2022
544dab9
changed the provider version
hemanthhp1229 Aug 6, 2022
3f920cf
added my private key file
hemanthhp1229 Aug 6, 2022
c6d4a25
playing with maps and list
hemanthhp1229 Aug 6, 2022
281b65d
switched the instance type
hemanthhp1229 Aug 6, 2022
bab2154
changed the output.tf file
Aug 6, 2022
9417651
changed the version number
Aug 6, 2022
4e81e50
used 'for' in outputs block
Aug 6, 2022
5b193fc
using tomap function
Aug 6, 2022
3c198c5
instance type offerings
Aug 6, 2022
1076bbc
semi dynamic version
Aug 6, 2022
1ffb88b
minor changes
Aug 6, 2022
714c163
changed the v3 version
Aug 7, 2022
415f524
changed the v3 version
Aug 7, 2022
2b7e5d5
changed the v3 version
Aug 7, 2022
ebaed08
changed the v3 version
Aug 7, 2022
d113edc
changed the v3 version
Aug 7, 2022
bdb75bc
added version 4 output
Aug 7, 2022
236fafa
updated the v4 output block
Aug 7, 2022
8bddb63
changed the code
hemanthhp1229 Aug 23, 2022
4e28291
changed the files
Sep 9, 2022
8f584bc
saving files
Sep 9, 2022
9eff99e
Merge branch 'version-v1' of https://github.com/hemanthhp1229/terrafo…
hemanthhp1229 Sep 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ provider "aws" {

# Resource Block
resource "aws_instance" "ec2demo" {
ami = "ami-0533f2ba8a1995cf9" # Amazon Linux in us-east-1, update as per your region
ami = "ami-0cff7528ff583bf9a" # Amazon Linux in us-east-1, update as per your region
instance_type = "t2.micro"
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Terraform Block
terraform {
required_version = "~> 0.14" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx
required_version = "~>1.2.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "4.23.0"
}
}
}
# Provider Block
provider "aws" {
region = "us-east-1"
}
}

provider "aws" {
region = "us-east-1"
profile = "default"
}
/*
Note-1: AWS Credentials Profile (profile = "default") configured on your local desktop terminal
$HOME/.aws/credentials
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Terraform Block
terraform {
required_version = "~> 0.14" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx
required_version = "~> 1.2.0" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx
required_providers {
aws = {
source = "hashicorp/aws"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# Input Variables
# AWS Region
variable "aws_region" {
description = "Region in which AWS Resources to be created"
description = "Region of aws resources"
type = string
default = "us-east-1"
}

}
# AWS EC2 Instance Type
variable "instance_type" {
description = "EC2 Instnace Type"
description = "EC2 instance type"
type = string
default = "t3.micro"
default = "t2.micro"


}

# AWS EC2 Instance Key Pair

variable "instance_keypair" {
description = "AWS EC2 Key Pair that need to be associated with EC2 Instance"
description = "aws keypair to login"
type = string
default = "terraform-key"
default = "myterraformkeypair"

}


Original file line number Diff line number Diff line change
@@ -1,56 +1,55 @@
# Create Security Group - SSH Traffic
resource "aws_security_group" "vpc-ssh" {
name = "vpc-ssh"
description = "Dev VPC SSH"
resource "aws_security_group" "allow_ssh" {
name = "allow_ssh"
description = "Allow ssh into instance"

ingress {
description = "Allow Port 22"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "TLS from 22"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
# ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block]
}

egress {
description = "Allow all ip and ports outbound"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}

tags = {
Name = "vpc-ssh"
Name = "allow ssh traffic"
}
}

# Create Security Group - Web Traffic
resource "aws_security_group" "vpc-web" {
name = "vpc-web"
description = "Dev VPC Web"
# allow web traffic



resource "aws_security_group" "allow_web" {
name = "allow_web"
description = "Allow http traffic into instance"

ingress {
description = "Allow Port 80"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "allow traffic from web"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
# ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block]
}
ingress {
description = "Allow Port 443"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

egress {
description = "Allow all ip and ports outbound"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}

tags = {
Name = "vpc-web"
}
}

Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# Get latest AMI ID for Amazon Linux2 OS
data "aws_ami" "amzlinux2" {
data "aws_ami" "amz_linux2" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["amzn2-ami-hvm-*-gp2"]
values = ["amzn2-ami-kernel-5.10-hvm-*-gp2"]
}

filter {
name = "root-device-type"
values = ["ebs"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
filter {
name = "architecture"
values = ["x86_64"]
}
}
}

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# EC2 Instance
resource "aws_instance" "myec2vm" {
ami = data.aws_ami.amzlinux2.id
ami = data.aws_ami.amz_linux2.id
instance_type = var.instance_type
user_data = file("${path.module}/app1-install.sh")
key_name = var.instance_keypair
vpc_security_group_ids = [ aws_security_group.vpc-ssh.id, aws_security_group.vpc-web.id ]
vpc_security_group_ids = [ aws_security_group.allow_ssh.id, aws_security_group.allow_web.id ]
tags = {
"Name" = "EC2 Demo 2"
"Name" = "MyDemoEC2"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Terraform Output Values

# EC2 Instance Public IP
output "instance_publicip" {
description = "EC2 Instance Public IP"
value = aws_instance.myec2vm.public_ip
description = "ec2 instance public ip"
value = aws_instance.myec2vm.public_ip

}

# EC2 Instance Public DNS
output "instance_publicdns" {
description = "EC2 Instance Public DNS"
value = aws_instance.myec2vm.public_dns
description = "ec2 instance public ip"
value = aws_instance.myec2vm.public_dns

}
Original file line number Diff line number Diff line change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izK7gTe1p
YtFPT8cihxObsX6rOaRSriqeaPU/TKQ+8V3tY60CgYAs9tKrj+gEjDrvQwPV4GHU
GhNC413D8w/KCK6uKASYfadu95vLaw2q44AImMdlPMdMT/ClADqGhWCTTrlSPymH
tKHgAonFJOP/MXix29JPjJ0n60Hj4phsqfFenwrAoE9EDzbtg7X+/MKsGs6m0kQ6
Yep33Z6x8XKHOfukvV70kQKBgHyUjZavTn2+pS1beAEGgmg7CehL5MELf8JUKlzd
AQ8nlawnbPhD1RI2SumlpXhE7n75tkdKlPpRiK+vLH/MYwRahqvxNwjHJLmpf1++
ls9cLLQNFSZmXnRfkJnfMd9wWVPdoC2xFI7vLWf2eB/8/ql10nN/OuHSRFf32L6Z
zFcBAoGBAN6jcUyoeFH8s6vE1jw8uxWsA8+UiBtDuXp33FkaI3ZzjFCK2oAbAoCU
ZT4IFxFiiKKEAtmt7ecgT6KUQj6a21zspSH6JCIFHtEFrNS6oLSGwdizeS385LAK
31fwk/U1tJQYxlXiwquXQltcXbdgEyiHTiyxRGmz1QzQE9QF5hKe
-----END RSA PRIVATE KEY-----

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ sudo yum update -y
sudo yum install -y httpd
sudo systemctl enable httpd
sudo service httpd start
sudo echo '<h1>Welcome to StackSimplify - APP-1</h1>' | sudo tee /var/www/html/index.html
sudo echo '<h1>Welcome to Speakup - APP-1</h1>' | sudo tee /var/www/html/index.html
sudo mkdir /var/www/html/app1
sudo echo '<!DOCTYPE html> <html> <body style="background-color:rgb(250, 210, 210);"> <h1>Welcome to Stack Simplify - APP-1</h1> <p>Terraform Demo</p> <p>Application Version: V1</p> </body></html>' | sudo tee /var/www/html/app1/index.html
sudo echo '<!DOCTYPE html> <html> <body style="background-color:rgb(250, 210, 210);"> <h1>Welcome to Mindtree - APP-1</h1> <p>Terraform Demo</p> <p>Application Version: V1</p> </body></html>' | sudo tee /var/www/html/app1/index.html
sudo curl http://169.254.169.254/latest/dynamic/instance-identity/document -o /var/www/html/app1/metadata.html


Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Terraform Block
terraform {
required_version = "~> 0.14" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx
required_version = "~> 1.2.0" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.25.0"
}
}
}

# Provider Block
provider "aws" {
region = var.aws_region

}


/*
Note-1: AWS Credentials Profile (profile = "default") configured on your local desktop terminal
$HOME/.aws/credentials
Expand Down
Loading