Skip to content

Commit 68eeddf

Browse files
authored
Merge pull request #4 from craine-io/add-ec2-instance-in-main-tf
Add EC2 instance resource in main.tf with outputs
2 parents b86f40d + f09bfb2 commit 68eeddf

File tree

2 files changed

+17
-34
lines changed

2 files changed

+17
-34
lines changed

main.tf

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,14 @@ resource "aws_security_group" "web" {
103103
}
104104
}
105105

106-
# EC2 instance will be added here by the AI agent
107-
# Example:
108-
# resource "aws_instance" "web" {
109-
# ami = "ami-0c55b159cbfafe1f0"
110-
# instance_type = "t2.micro"
111-
# subnet_id = aws_subnet.public.id
112-
# security_groups = [aws_security_group.web.id]
113-
#
114-
# tags = {
115-
# Name = "web-server"
116-
# }
117-
# }
106+
# EC2 instance resource
107+
resource "aws_instance" "web" {
108+
ami = var.ami_id
109+
instance_type = var.instance_type
110+
subnet_id = aws_subnet.public.id
111+
vpc_security_group_ids = [aws_security_group.web.id]
112+
113+
tags = {
114+
Name = "web-server"
115+
}
116+
}

outputs.tf

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
output "vpc_id" {
2-
description = "ID of the VPC"
3-
value = aws_vpc.main.id
1+
output "instance_id" {
2+
description = "ID of the EC2 instance"
3+
value = aws_instance.web.id
44
}
55

6-
output "subnet_id" {
7-
description = "ID of the public subnet"
8-
value = aws_subnet.public.id
6+
output "instance_public_ip" {
7+
description = "Public IP address of the EC2 instance"
8+
value = aws_instance.web.public_ip
99
}
10-
11-
output "security_group_id" {
12-
description = "ID of the security group"
13-
value = aws_security_group.web.id
14-
}
15-
16-
# Future outputs for the EC2 instance
17-
# output "instance_id" {
18-
# description = "ID of the EC2 instance"
19-
# value = aws_instance.web.id
20-
# }
21-
#
22-
# output "public_ip" {
23-
# description = "Public IP of the EC2 instance"
24-
# value = aws_instance.web.public_ip
25-
# }

0 commit comments

Comments
 (0)