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 +} diff --git a/dev-ec2/main.tf b/dev-ec2/main.tf index 4ef07f2..c7e3744 100644 --- a/dev-ec2/main.tf +++ b/dev-ec2/main.tf @@ -20,6 +20,6 @@ provider "aws" { resource "aws_ssm_parameter" "foo" { name = "/dev/ec2" type = "String" - value = "ec2 instance2" + value = "ec2 instance3" }