Skip to content

Commit

Permalink
Add first 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 7c8e1f5 commit 4a23af5
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,32 @@ resource "aws_subnet" "second" {
tags = {
Name = "second_subnet"
}
}
}

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"
}
}

0 comments on commit 4a23af5

Please sign in to comment.