@@ -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 aws = {
88 source = " hashicorp/aws"
@@ -11,53 +11,133 @@ terraform {
1111 }
1212}
1313
14- # Last updated 2022-05-31
14+ # Last updated 2023-03-14
1515# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort'
16- variable "region" {
17- description = " What region should your workspace live in?"
16+ data "coder_parameter" "region" {
17+ name = " Region"
18+ description = " The region to deploy the workspace in."
1819 default = " us-east-1"
19- validation {
20- condition = contains ([
21- " ap-northeast-1" ,
22- " ap-northeast-2" ,
23- " ap-northeast-3" ,
24- " ap-south-1" ,
25- " ap-southeast-1" ,
26- " ap-southeast-2" ,
27- " ca-central-1" ,
28- " eu-central-1" ,
29- " eu-north-1" ,
30- " eu-west-1" ,
31- " eu-west-2" ,
32- " eu-west-3" ,
33- " sa-east-1" ,
34- " us-east-1" ,
35- " us-east-2" ,
36- " us-west-1" ,
37- " us-west-2"
38- ], var. region )
39- error_message = " Invalid region!"
20+ mutable = false
21+ option {
22+ name = " Asia Pacific (Tokyo)"
23+ value = " ap-northeast-1"
24+ icon = " /emojis/1f1ef-1f1f5.png"
25+ }
26+ option {
27+ name = " Asia Pacific (Seoul)"
28+ value = " ap-northeast-2"
29+ icon = " /emojis/1f1f0-1f1f7.png"
30+ }
31+ option {
32+ name = " Asia Pacific (Osaka-Local)"
33+ value = " ap-northeast-3"
34+ icon = " /emojis/1f1f0-1f1f7.png"
35+ }
36+ option {
37+ name = " Asia Pacific (Mumbai)"
38+ value = " ap-south-1"
39+ icon = " /emojis/1f1f0-1f1f7.png"
40+ }
41+ option {
42+ name = " Asia Pacific (Singapore)"
43+ value = " ap-southeast-1"
44+ icon = " /emojis/1f1f0-1f1f7.png"
45+ }
46+ option {
47+ name = " Asia Pacific (Sydney)"
48+ value = " ap-southeast-2"
49+ icon = " /emojis/1f1f0-1f1f7.png"
50+ }
51+ option {
52+ name = " Canada (Central)"
53+ value = " ca-central-1"
54+ icon = " /emojis/1f1e8-1f1e6.png"
55+ }
56+ option {
57+ name = " EU (Frankfurt)"
58+ value = " eu-central-1"
59+ icon = " /emojis/1f1ea-1f1fa.png"
60+ }
61+ option {
62+ name = " EU (Stockholm)"
63+ value = " eu-north-1"
64+ icon = " /emojis/1f1ea-1f1fa.png"
65+ }
66+ option {
67+ name = " EU (Ireland)"
68+ value = " eu-west-1"
69+ icon = " /emojis/1f1ea-1f1fa.png"
70+ }
71+ option {
72+ name = " EU (London)"
73+ value = " eu-west-2"
74+ icon = " /emojis/1f1ea-1f1fa.png"
75+ }
76+ option {
77+ name = " EU (Paris)"
78+ value = " eu-west-3"
79+ icon = " /emojis/1f1ea-1f1fa.png"
80+ }
81+ option {
82+ name = " South America (São Paulo)"
83+ value = " sa-east-1"
84+ icon = " /emojis/1f1e7-1f1f7.png"
85+ }
86+ option {
87+ name = " US East (N. Virginia)"
88+ value = " us-east-1"
89+ icon = " /emojis/1f1fa-1f1f8.png"
90+ }
91+ option {
92+ name = " US East (Ohio)"
93+ value = " us-east-2"
94+ icon = " /emojis/1f1fa-1f1f8.png"
95+ }
96+ option {
97+ name = " US West (N. California)"
98+ value = " us-west-1"
99+ icon = " /emojis/1f1fa-1f1f8.png"
100+ }
101+ option {
102+ name = " US West (Oregon)"
103+ value = " us-west-2"
104+ icon = " /emojis/1f1fa-1f1f8.png"
40105 }
41106}
42107
43- variable "instance_type" {
108+ data "coder_parameter" "instance_type" {
109+ name = " Instance Type"
44110 description = " What instance type should your workspace use?"
45111 default = " t3.micro"
46- validation {
47- condition = contains ([
48- " t3.micro" ,
49- " t3.small" ,
50- " t3.medium" ,
51- " t3.large" ,
52- " t3.xlarge" ,
53- " t3.2xlarge" ,
54- ], var. instance_type )
55- error_message = " Invalid instance type!"
112+ mutable = false
113+ option {
114+ name = " 2 vCPU, 1 GiB RAM"
115+ value = " t3.micro"
116+ }
117+ option {
118+ name = " 2 vCPU, 2 GiB RAM"
119+ value = " t3.small"
120+ }
121+ option {
122+ name = " 2 vCPU, 4 GiB RAM"
123+ value = " t3.medium"
124+ }
125+ option {
126+ name = " 2 vCPU, 8 GiB RAM"
127+ value = " t3.large"
128+ }
129+ option {
130+ name = " 4 vCPU, 16 GiB RAM"
131+ value = " t3.xlarge"
132+ }
133+ option {
134+ name = " 8 vCPU, 32 GiB RAM"
135+ value = " t3.2xlarge"
56136 }
57137}
58138
59139provider "aws" {
60- region = var . region
140+ region = data . coder_parameter . region . value
61141}
62142
63143data "coder_workspace" "me" {
@@ -77,10 +157,9 @@ data "aws_ami" "ubuntu" {
77157}
78158
79159resource "coder_agent" "main" {
80- arch = " amd64"
81- auth = " aws-instance-identity"
82- os = " linux"
83-
160+ arch = " amd64"
161+ auth = " aws-instance-identity"
162+ os = " linux"
84163 login_before_ready = false
85164 startup_script_timeout = 180
86165 startup_script = <<- EOT
174253
175254resource "aws_instance" "dev" {
176255 ami = data. aws_ami . ubuntu . id
177- availability_zone = " ${ var . region } a"
178- instance_type = var . instance_type
256+ availability_zone = " ${ data . coder_parameter . region . value } a"
257+ instance_type = data . coder_parameter . instance_type . value
179258
180259 user_data = data. coder_workspace . me . transition == " start" ? local. user_data_start : local. user_data_end
181260 tags = {
@@ -189,7 +268,7 @@ resource "coder_metadata" "workspace_info" {
189268 resource_id = aws_instance. dev . id
190269 item {
191270 key = " region"
192- value = var . region
271+ value = data . coder_parameter . region . value
193272 }
194273 item {
195274 key = " instance type"
0 commit comments