From 7ad9cb7e0ddf9fd2e384d3783645e89813b692ff Mon Sep 17 00:00:00 2001 From: Mohamed Habib Date: Thu, 21 Nov 2024 17:22:28 +0000 Subject: [PATCH] Create ec2.tf --- dev-ec2/ec2.tf | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 dev-ec2/ec2.tf diff --git a/dev-ec2/ec2.tf b/dev-ec2/ec2.tf new file mode 100644 index 0000000..07daaa6 --- /dev/null +++ b/dev-ec2/ec2.tf @@ -0,0 +1,33 @@ + +resource "aws_instance" "example" { + ami = "ami-0e731c8a588258d0d" # Amazon Linux 2023 AMI in us-east-1 + instance_type = "t2.micro" + + tags = { + Name = "example-instance" + } + + vpc_security_group_ids = [aws_security_group.instance.id] +} + +resource "aws_security_group" "instance" { + name = "example-instance" + + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } +} + +output "public_ip" { + value = aws_instance.example.public_ip +}