Skip to content

Commit

Permalink
Add second EC2 instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Syuqri authored and Syuqri committed Dec 29, 2023
1 parent 4a23af5 commit aad9d5c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,31 @@ resource "aws_instance" "first" {
Name = "first_instance"
}
}

resource "aws_security_group" "second_instance_sg" {
name = "second_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 = "second_instance_sg"
}
}

resource "aws_instance" "second" {
ami = data.aws_ami.aml2.id
instance_type = "t3.micro"
subnet_id = aws_subnet.second.id
vpc_security_group_ids = [aws_security_group.second_instance_sg.id]
iam_instance_profile = aws_iam_instance_profile.ec2_instance_profile.name

tags = {
Name = "second_instance"
}
}

0 comments on commit aad9d5c

Please sign in to comment.