-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparsec.tf
More file actions
125 lines (100 loc) · 2.03 KB
/
parsec.tf
File metadata and controls
125 lines (100 loc) · 2.03 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Variables
variable "parsec_authcode" {
type = "string"
}
variable "aws_region" {
type = "string"
}
variable "aws_vpc" {
type = "string"
}
variable "aws_subnet" {
type = "string"
}
# Template
provider "aws" {
region = "${var.aws_region}"
}
data "aws_ami" "parsec" {
most_recent = true
filter {
name = "name"
values = ["ParsecRun-3"]
}
}
resource "aws_security_group" "parsec" {
vpc_id = "${var.aws_vpc}"
name = "parsec"
description = "Allow inbound Parsec traffic and all outbound."
ingress {
from_port = 8000
to_port = 8004
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 5900
to_port = 5900
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 5900
to_port = 5900
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 8000
to_port = 8004
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 8000
to_port = 8004
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
data "template_file" "user_data" {
template = "${file("user_data.tmpl")}"
vars {
authcode = "${var.parsec_authcode}"
}
}
resource "aws_spot_instance_request" "parsec" {
spot_price = "0.7"
ami = "${data.aws_ami.parsec.id}"
subnet_id = "${var.aws_subnet}"
instance_type = "g2.2xlarge"
tags {
Name = "ParsecServer"
}
root_block_device {
volume_size = 50
}
ebs_block_device {
volume_size = 100
volume_type = "gp2"
device_name = "xvdg"
}
user_data = "${data.template_file.user_data.rendered}"
vpc_security_group_ids = ["${aws_security_group.parsec.id}"]
associate_public_ip_address = true
}
output "aws_region" {
value = "${var.aws_region}"
}
output "aws_subnet" {
value = "${var.aws_subnet}"
}
output "aws_vpc" {
value = "${var.aws_vpc}"
}