Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LondheShubham153 authored Aug 30, 2024
1 parent 81578ac commit 43e8c26
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
63 changes: 63 additions & 0 deletions terraform/ec2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
resource "aws_key_pair" "deployer" {
key_name = "terra-automate-key"
public_key = file("/Users/shubham/Documents/work/TrainWithShubham/terra-practice/terra-key.pub")
}

resource "aws_default_vpc" "default" {

}

resource "aws_security_group" "allow_user_to_connect" {
name = "allow TLS"
description = "Allow user to connect"
vpc_id = aws_default_vpc.default.id
ingress {
description = "port 22 allow"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

egress {
description = " allow all outgoing traffic "
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
description = "port 80 allow"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
description = "port 443 allow"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

tags = {
Name = "mysecurity"
}
}

resource "aws_instance" "testinstance" {
ami = var.ami_id
instance_type = var.instance_type
key_name = aws_key_pair.deployer.key_name
security_groups = [aws_security_group.allow_user_to_connect.name]
tags = {
Name = "Automate"
}
root_block_device {
volume_size = 30
volume_type = "gp3"
}
}
14 changes: 14 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variable "aws_region" {
description = "AWS region where resources will be provisioned"
default = "us-east-2"
}

variable "ami_id" {
description = "AMI ID for the EC2 instance"
default = "ami-085f9c64a9b75eed5"
}

variable "instance_type" {
description = "Instance type for the EC2 instance"
default = "t2.large"
}

0 comments on commit 43e8c26

Please sign in to comment.