63 lines
1.3 KiB
HCL
63 lines
1.3 KiB
HCL
provider "aws" {
|
|
region = "us-east-1" # Change this to your preferred region
|
|
}
|
|
|
|
resource "aws_security_group" "ec2_sg" {
|
|
name = "aviary-sg"
|
|
description = "Allow SSH inbound traffic"
|
|
|
|
ingress {
|
|
from_port = 22
|
|
to_port = 22
|
|
protocol = "tcp"
|
|
cidr_blocks = ["108.237.185.23/32"]
|
|
}
|
|
|
|
ingress {
|
|
from_port = 80
|
|
to_port = 80
|
|
protocol = "tcp"
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
|
|
ingress {
|
|
from_port = 443
|
|
to_port = 443
|
|
protocol = "tcp"
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
|
|
ingress {
|
|
from_port = 51820
|
|
to_port = 51820
|
|
protocol = "udp"
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
|
|
egress {
|
|
from_port = 0
|
|
to_port = 0
|
|
protocol = "-1"
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
}
|
|
|
|
resource "aws_instance" "ec2_vm" {
|
|
ami = "ami-02a53b0d62d37a757" # Replace with a valid AMI ID for your region
|
|
instance_type = "t2.micro" # Free tier eligible instance type
|
|
security_groups = [aws_security_group.ec2_sg.name]
|
|
key_name = "theocorp" # Replace with your AWS key pair name
|
|
|
|
tags = {
|
|
Name = "aviary"
|
|
}
|
|
}
|
|
|
|
resource "aws_eip" "ec2_eip" {
|
|
instance = aws_instance.ec2_vm.id
|
|
}
|
|
|
|
output "instance_public_ip" {
|
|
description = "Public IP of the EC2 instance"
|
|
value = aws_eip.ec2_eip.public_ip
|
|
} |