Skip to content

Commit ad0f454

Browse files
committed
update azure-vm
1 parent 3c3c0ef commit ad0f454

File tree

1 file changed

+171
-60
lines changed
  • examples/templates/azure-linux

1 file changed

+171
-60
lines changed

examples/templates/azure-linux/main.tf

Lines changed: 171 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "~> 0.6.12"
5+
version = "~> 0.6.17"
66
}
77
azurerm = {
88
source = "hashicorp/azurerm"
@@ -11,64 +11,176 @@ terraform {
1111
}
1212
}
1313

14-
variable "location" {
14+
data "coder_parameter" "location" {
15+
name = "Location"
1516
description = "What location should your workspace live in?"
1617
default = "eastus"
17-
validation {
18-
condition = contains([
19-
"eastus",
20-
"southcentralus",
21-
"westus2",
22-
"australiaeast",
23-
"southeastasia",
24-
"northeurope",
25-
"westeurope",
26-
"centralindia",
27-
"eastasia",
28-
"japaneast",
29-
"brazilsouth",
30-
"asia",
31-
"asiapacific",
32-
"australia",
33-
"brazil",
34-
"india",
35-
"japan",
36-
"southafrica",
37-
"switzerland",
38-
"uae",
39-
], var.location)
40-
error_message = "Invalid location!"
41-
}
42-
}
43-
44-
variable "instance_type" {
18+
icon = "/emojis/"
19+
mutable = false
20+
option {
21+
name = "East US"
22+
value = "eastus"
23+
icon = "/emojis/1f1fa-1f1f8.png"
24+
}
25+
option {
26+
name = "South Central US"
27+
value = "southcentralus"
28+
icon = "/emojis/1f1fa-1f1f8.png"
29+
}
30+
option {
31+
name = "West US 2"
32+
value = "westus2"
33+
icon = "/emojis/1f1fa-1f1f8.png"
34+
}
35+
option {
36+
name = "Australia East"
37+
value = "australiaeast"
38+
icon = "/emojis/1f1e6-1f1fa.png"
39+
}
40+
option {
41+
name = "Southeast Asia"
42+
value = "southeastasia"
43+
icon = "/emojis/1f1f8-1f1e6.png"
44+
}
45+
option {
46+
name = "North Europe"
47+
value = "northeurope"
48+
icon = "/emojis/1f1f3-1f1ea.png"
49+
}
50+
option {
51+
name = "West Europe"
52+
value = "westeurope"
53+
icon = "/emojis/1f1f3-1f1ea.png"
54+
}
55+
option {
56+
name = "Central India"
57+
value = "centralindia"
58+
icon = "/emojis/1f1ee-1f1f3.png"
59+
}
60+
option {
61+
name = "East Asia"
62+
value = "eastasia"
63+
icon = "/emojis/1f1f0-1f1f7.png"
64+
}
65+
option {
66+
name = "Japan East"
67+
value = "japaneast"
68+
icon = "/emojis/1f1ef-1f1f5.png"
69+
}
70+
option {
71+
name = "Brazil South"
72+
value = "brazilsouth"
73+
icon = "/emojis/1f1e7-1f1f7.png"
74+
}
75+
option {
76+
name = "Asia"
77+
value = "asia"
78+
icon = "/emojis/1f1f0-1f1f7.png"
79+
}
80+
option {
81+
name = "Asia Pacific"
82+
value = "asiapacific"
83+
icon = "/emojis/1f1f0-1f1f7.png"
84+
}
85+
option {
86+
name = "Australia"
87+
value = "australia"
88+
icon = "/emojis/1f1e6-1f1fa.png"
89+
}
90+
option {
91+
name = "Brazil"
92+
value = "brazil"
93+
icon = "/emojis/1f1e7-1f1f7.png"
94+
}
95+
option {
96+
name = "India"
97+
value = "india"
98+
icon = "/emojis/1f1ee-1f1f3.png"
99+
}
100+
option {
101+
name = "Japan"
102+
value = "japan"
103+
icon = "/emojis/1f1ef-1f1f5.png"
104+
}
105+
option {
106+
name = "South Africa"
107+
value = "southafrica"
108+
icon = "/emojis/1f1ff-1f1e6.png"
109+
}
110+
option {
111+
name = "Switzerland"
112+
value = "switzerland"
113+
icon = "/emojis/1f1e8-1f1ed.png"
114+
}
115+
option {
116+
name = "UAE"
117+
value = "uae"
118+
icon = "/emojis/1f1e6-1f1ea.png"
119+
}
120+
}
121+
122+
data "coder_parameter" "instance_type" {
123+
name = "Instance Type"
45124
description = "What instance type should your workspace use?"
46125
default = "Standard_B4ms"
47-
validation {
48-
condition = contains([
49-
"Standard_B1ms",
50-
"Standard_B2ms",
51-
"Standard_B4ms",
52-
"Standard_B8ms",
53-
"Standard_B12ms",
54-
"Standard_B16ms",
55-
"Standard_D2as_v5",
56-
"Standard_D4as_v5",
57-
"Standard_D8as_v5",
58-
"Standard_D16as_v5",
59-
"Standard_D32as_v5",
60-
], var.instance_type)
61-
error_message = "Invalid instance type!"
62-
}
63-
}
64-
65-
variable "home_size" {
66-
type = number
126+
icon = "/icons/azure.png"
127+
mutable = false
128+
option {
129+
name = "1 vCPU, 2 GiB RAM"
130+
value = "Standard_B1ms"
131+
}
132+
option {
133+
name = "2 vCPU, 8 GiB RAM"
134+
value = "Standard_B2ms"
135+
}
136+
option {
137+
name = "4 vCPU, 16 GiB RAM"
138+
value = "Standard_B4ms"
139+
}
140+
option {
141+
name = "8 vCPU, 32 GiB RAM"
142+
value = "Standard_B8ms"
143+
}
144+
option {
145+
name = "12 vCPU, 48 GiB RAM"
146+
value = "Standard_B12ms"
147+
}
148+
option {
149+
name = "16 vCPU, 64 GiB RAM"
150+
value = "Standard_B16ms"
151+
}
152+
option {
153+
name = "2 vCPU, 8 GiB RAM"
154+
value = "Standard_D2as_v5"
155+
}
156+
option {
157+
name = "4 vCPU, 16 GiB RAM"
158+
value = "Standard_D4as_v5"
159+
}
160+
option {
161+
name = "8 vCPU, 32 GiB RAM"
162+
value = "Standard_D8as_v5"
163+
}
164+
option {
165+
name = "16 vCPU, 64 GiB RAM"
166+
value = "Standard_D16as_v5"
167+
}
168+
option {
169+
name = "32 vCPU, 128 GiB RAM"
170+
value = "Standard_D32as_v5"
171+
}
172+
}
173+
174+
data "coder_parameter" "home_size" {
175+
name = "Home Volume Size"
67176
description = "How large would you like your home volume to be (in GB)?"
68177
default = 20
178+
type = "number"
179+
icon = "/icons/azure.png"
180+
mutable = false
69181
validation {
70-
condition = var.home_size >= 1
71-
error_message = "Value must be greater than or equal to 1."
182+
min = 1
183+
max = 1024
72184
}
73185
}
74186

@@ -80,10 +192,9 @@ data "coder_workspace" "me" {
80192
}
81193

82194
resource "coder_agent" "main" {
83-
arch = "amd64"
84-
os = "linux"
85-
auth = "azure-instance-identity"
86-
195+
arch = "amd64"
196+
os = "linux"
197+
auth = "azure-instance-identity"
87198
login_before_ready = false
88199
}
89200

@@ -99,7 +210,7 @@ locals {
99210

100211
resource "azurerm_resource_group" "main" {
101212
name = "${local.prefix}-resources"
102-
location = var.location
213+
location = data.coder_parameter.location.value
103214

104215
tags = {
105216
Coder_Provisioned = "true"
@@ -160,7 +271,7 @@ resource "azurerm_managed_disk" "home" {
160271
name = "home"
161272
resource_group_name = azurerm_resource_group.main.name
162273
storage_account_type = "StandardSSD_LRS"
163-
disk_size_gb = var.home_size
274+
disk_size_gb = data.coder_parameter.home_size.value
164275
}
165276

166277
// azurerm requires an SSH key (or password) for an admin user or it won't start a VM. However,
@@ -175,7 +286,7 @@ resource "azurerm_linux_virtual_machine" "main" {
175286
name = "vm"
176287
resource_group_name = azurerm_resource_group.main.name
177288
location = azurerm_resource_group.main.location
178-
size = var.instance_type
289+
size = data.coder_parameter.instance_type.value
179290
// cloud-init overwrites this, so the value here doesn't matter
180291
admin_username = "adminuser"
181292
admin_ssh_key {
@@ -227,6 +338,6 @@ resource "coder_metadata" "home_info" {
227338

228339
item {
229340
key = "size"
230-
value = "${var.home_size} GiB"
341+
value = "${data.coder_parameter.home_size.value} GiB"
231342
}
232343
}

0 commit comments

Comments
 (0)