-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstance.tf
More file actions
63 lines (55 loc) · 1.57 KB
/
instance.tf
File metadata and controls
63 lines (55 loc) · 1.57 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
resource "aws_instance" "minecraft-server" {
ami = "${lookup(var.AMIS, var.AWS_REGION)}"
instance_type = "t2.micro"
subnet_id = "${aws_subnet.minecraft-server.id}"
vpc_security_group_ids = ["${aws_security_group.minecraft-server.id}"]
key_name = "${aws_key_pair.minecraft-server.key_name}"
iam_instance_profile = "${aws_iam_instance_profile.minecraft-server.id}"
tags {
Name = "Minecraft Server"
Group = "Minecraft"
}
provisioner "file" {
source = "script.sh"
destination = "/tmp/script.sh"
}
provisioner "file" {
source = "minecraft.yml"
destination = " /tmp/minecraft.yml"
}
provisioner "remote-exec" {
inline = [
"mkdir /home/ubuntu/scripts",
]
}
provisioner "file" {
source = "./scripts/backup_world.sh"
destination = "/home/ubuntu/scripts/backup_world.sh"
}
provisioner "file" {
source = "./scripts/restore_world.sh"
destination = "/home/ubuntu/scripts/restore_world.sh"
}
provisioner "file" {
source = "./scripts/whos_online.sh"
destination = "/home/ubuntu/scripts/whos_online.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/script.sh",
"sudo /tmp/script.sh ${var.S3_BUCKET_NAME}",
]
}
connection {
agent = "false"
user = "${var.INSTANCE_USERNAME}"
private_key = "${file("${var.PATH_TO_PRIVATE_KEY}")}"
}
}
output "minecraft-server_IP" {
value = "${aws_instance.minecraft-server.public_ip}"
}
resource "aws_key_pair" "minecraft-server" {
key_name = "minecraft-key"
public_key = "${file("${var.PATH_TO_PUBLIC_KEY}")}"
}