-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.hcl
149 lines (123 loc) · 2.75 KB
/
main.hcl
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
backend {
disabled = !var.backend_remote
// sends it to remote backend
}
backend {
disabled = !var.backend_cloud
// uses jumppad cloud
// fields overlap mostly with remote
// but doesnt need an address
}
backend {
disabled = !var.backend_local
// sends it to local backend (gets deleted on purge)
}
*/
variable "docs_url" {
default = "http://localhost"
}
variable "vscode_token" {
default = "token"
}
resource "network" "main" {
subnet = "10.100.0.0/16"
}
resource "copy" "workspace" {
source = "./workspace"
destination = data("terraform")
permissions = "0755"
}
module "course" {
source = "${dir()}/course"
variables = {
terraform_target = "resource.container.vscode"
working_directory = "/terraform_basics"
// future idea
// working_directory = resource.container.vscode.volume.workdir.destination
}
}
resource "docs" "docs" {
network {
id = resource.network.main.meta.id
}
/*
have docs support multiple paths that get combined into docs?
grabs all the books from the library and generates navigation
mounts the library to a volume
*/
// logo {
// url = "https://companieslogo.com/img/orig/HCP.D-be08ca6f.png"
// width = 32
// height = 32
// }
content = [
module.course.output.book
]
assets = "${dir()}/assets"
}
resource "template" "vscode_jumppad" {
source = <<-EOF
{
"tabs": [
{
"name": "Docs",
"uri": "${variable.docs_url}",
"type": "browser",
"active": true
},
{
"name": "Terminal",
"location": "editor",
"type": "terminal"
}
]
}
EOF
destination = "${data("vscode")}/workspace.json"
}
resource "container" "vscode" {
network {
id = resource.network.main.meta.id
}
image {
name = "ghcr.io/jumppad-labs/terraform-workshop:v0.4.0"
}
volume {
source = "${dir()}/scripts"
destination = "/var/lib/jumppad/"
}
volume {
source = data("terraform")
destination = "/terraform_basics"
}
volume {
source = resource.template.vscode_jumppad.destination
destination = "/terraform_basics/.vscode/workspace.json"
}
volume {
source = "/var/run/docker.sock"
destination = "/var/run/docker.sock"
}
environment = {
EXTENSIONS = "hashicorp.hcl,hashicorp.terraform"
CONNECTION_TOKEN = variable.vscode_token
DEFAULT_FOLDER = "/terraform_basics"
}
port {
local = 8000
remote = 8000
host = 8000
}
health_check {
timeout = "100s"
http {
address = "http://${resource.docs.docs.fqdn}/docs/terraform_basics/introduction/what_is_terraform"
success_codes = [200]
}
http {
address = "http://localhost:8000/"
success_codes = [200, 302, 403]
}
}
}