diff --git a/main.tf b/main.tf index 780dd91..3c10d93 100644 --- a/main.tf +++ b/main.tf @@ -36,4 +36,32 @@ resource "aws_subnet" "second" { tags = { Name = "second_subnet" } -} \ No newline at end of file +} + +resource "aws_security_group" "first_instance_sg" { + name = "first_instance_sg" + vpc_id = aws_vpc.main.id + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + + tags = { + Name = "first_instance_sg" + } +} + +resource "aws_instance" "first" { + ami = data.aws_ami.aml2.id + instance_type = "t3.micro" + subnet_id = aws_subnet.first.id + vpc_security_group_ids = [aws_security_group.first_instance_sg.id] + iam_instance_profile = aws_iam_instance_profile.ec2_instance_profile.name + + tags = { + Name = "first_instance" + } +}