Skip to content

Commit 5e63201

Browse files
authored
change default aws linux instance type to t3.micro, reduce default template TTL (coder#2776)
- make default template max TTL 24 hours (still less than 168) - make default workspace autostop 2 hours unless specified otherwise - add instance type selector to aws templates
1 parent c07a45e commit 5e63201

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

cli/templatecreate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func templateCreate() *cobra.Command {
127127
cmd.Flags().StringVarP(&directory, "directory", "d", currentDirectory, "Specify the directory to create from")
128128
cmd.Flags().StringVarP(&provisioner, "test.provisioner", "", "terraform", "Customize the provisioner backend")
129129
cmd.Flags().StringVarP(&parameterFile, "parameter-file", "", "", "Specify a file path with parameter values.")
130-
cmd.Flags().DurationVarP(&maxTTL, "max-ttl", "", 168*time.Hour, "Specify a maximum TTL for workspaces created from this template.")
130+
cmd.Flags().DurationVarP(&maxTTL, "max-ttl", "", 24*time.Hour, "Specify a maximum TTL for workspaces created from this template.")
131131
cmd.Flags().DurationVarP(&minAutostartInterval, "min-autostart-interval", "", time.Hour, "Specify a minimum autostart interval for workspaces created from this template.")
132132
// This is for testing!
133133
err := cmd.Flags().MarkHidden("test.provisioner")

coderd/workspaces.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/coder/coder/codersdk"
3333
)
3434

35-
const workspaceDefaultTTL = 12 * time.Hour
35+
const workspaceDefaultTTL = 2 * time.Hour
3636

3737
func (api *API) workspace(rw http.ResponseWriter, r *http.Request) {
3838
workspace := httpmw.WorkspaceParam(r)

examples/templates/aws-linux/main.tf

+17-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ variable "region" {
3636
}
3737
}
3838

39+
variable "instance_type" {
40+
description = "What instance type should your workspace use?"
41+
default = "t3.micro"
42+
validation {
43+
condition = contains([
44+
"t3.micro",
45+
"t3.small",
46+
"t3.medium",
47+
"t3.large",
48+
"t3.xlarge",
49+
"t3.2xlarge",
50+
], var.instance_type)
51+
error_message = "Invalid instance type!"
52+
}
53+
}
54+
3955
provider "aws" {
4056
region = var.region
4157
}
@@ -130,7 +146,7 @@ EOT
130146
resource "aws_instance" "dev" {
131147
ami = data.aws_ami.ubuntu.id
132148
availability_zone = "${var.region}a"
133-
instance_type = "t3.xlarge"
149+
instance_type = "${var.instance_type}"
134150

135151
user_data = data.coder_workspace.me.transition == "start" ? local.user_data_start : local.user_data_end
136152
tags = {

examples/templates/aws-windows/main.tf

+17-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ variable "region" {
3636
}
3737
}
3838

39+
variable "instance_type" {
40+
description = "What instance type should your workspace use?"
41+
default = "t3.micro"
42+
validation {
43+
condition = contains([
44+
"t3.micro",
45+
"t3.small",
46+
"t3.medium",
47+
"t3.large",
48+
"t3.xlarge",
49+
"t3.2xlarge",
50+
], var.instance_type)
51+
error_message = "Invalid instance type!"
52+
}
53+
}
54+
3955
provider "aws" {
4056
region = var.region
4157
}
@@ -83,7 +99,7 @@ EOT
8399
resource "aws_instance" "dev" {
84100
ami = data.aws_ami.windows.id
85101
availability_zone = "${var.region}a"
86-
instance_type = "t3.micro"
102+
instance_type = "${var.instance_type}"
87103
count = 1
88104

89105
user_data = data.coder_workspace.me.transition == "start" ? local.user_data_start : local.user_data_end

0 commit comments

Comments
 (0)