forked from LondheShubham153/Wanderlust-Mega-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81578ac
commit 43e8c26
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |