-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2.tf
41 lines (31 loc) Β· 862 Bytes
/
ec2.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
resource "aws_eip" "web" {
instance = aws_instance.webserver.id
domain = "vpc"
}
resource "aws_instance" "webserver" {
ami = var.ec2_ami
instance_type = var.ec2_instance_type
subnet_id = aws_subnet.repick-vpc-public-subnet-1.id
key_name = aws_key_pair.web.id
vpc_security_group_ids = [aws_security_group.repick-sg.id]
associate_public_ip_address = true
user_data = file("user_data.sh")
lifecycle {
ignore_changes = [user_data]
}
tags = {
Name = "repick-server"
}
}
resource "aws_key_pair" "web" {
key_name = "repick-key"
public_key = file("./.ssh/repick-key.pub")
}
output "instance_id" {
description = "The ID of the instance"
value = aws_instance.webserver.id
}
output "public_ip" {
description = "The Public IP of the instance"
value = aws_eip.web.public_ip
}