Skip to content

change default aws linux instance type to t3.micro, reduce default template TTL #2776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/templatecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func templateCreate() *cobra.Command {
cmd.Flags().StringVarP(&directory, "directory", "d", currentDirectory, "Specify the directory to create from")
cmd.Flags().StringVarP(&provisioner, "test.provisioner", "", "terraform", "Customize the provisioner backend")
cmd.Flags().StringVarP(&parameterFile, "parameter-file", "", "", "Specify a file path with parameter values.")
cmd.Flags().DurationVarP(&maxTTL, "max-ttl", "", 168*time.Hour, "Specify a maximum TTL for workspaces created from this template.")
cmd.Flags().DurationVarP(&maxTTL, "max-ttl", "", 24*time.Hour, "Specify a maximum TTL for workspaces created from this template.")
cmd.Flags().DurationVarP(&minAutostartInterval, "min-autostart-interval", "", time.Hour, "Specify a minimum autostart interval for workspaces created from this template.")
// This is for testing!
err := cmd.Flags().MarkHidden("test.provisioner")
Expand Down
2 changes: 1 addition & 1 deletion coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/coder/coder/codersdk"
)

const workspaceDefaultTTL = 12 * time.Hour
const workspaceDefaultTTL = 2 * time.Hour

func (api *API) workspace(rw http.ResponseWriter, r *http.Request) {
workspace := httpmw.WorkspaceParam(r)
Expand Down
18 changes: 17 additions & 1 deletion examples/templates/aws-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ variable "region" {
}
}

variable "instance_type" {
description = "What instance type should your workspace use?"
default = "2C/1G: t3.micro"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had a few instances where defining the default skipped the prompt. I'm guessing this is not the case here? (Just checking.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall it being the case when I tested it!

Copy link
Member

@mafredri mafredri Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's probably fine 👍, could've been related to variables marked sensitive (and that behavior might've changed already, it was a while ago).

validation {
condition = contains([
"2C/1G: t3.micro",
"2C/2G: t3.small",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't immediately clear what "C" and "G" meant in this context. I eventually realized it was vCPU and GB RAM, but I think 2 vCPU / 2 GB RAM is clearer and it's not like we're hurting for space in this context, nor do the users have to type these values in our UX.

Unfortunately the vCPU number is a little misleading for T3 instances. Micro-large have the same number of vCPUs, and reading this you might conclude that they have the same CPU performance. They do not. Amazon throttles the CPUs except for short bursts and the amount of throttling is different for the different instance sizes. I'm not really sure what to suggest except to drop the stats and just include the instance type names. Up to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can drop the stats, I only put them in there so the instance types would show up in the right order :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you could do numbered list, 1. t3.micro, 2. t3.small if you want to maintain order? 😄

"2C/4G: t3.medium",
"2C/8G: t3.large",
"4C/16G: t3.xlarge",
"8C/32G: t3.2xlarge",
], var.instance_type)
error_message = "Invalid instance type!"
}
}

provider "aws" {
region = var.region
}
Expand Down Expand Up @@ -130,7 +146,7 @@ EOT
resource "aws_instance" "dev" {
ami = data.aws_ami.ubuntu.id
availability_zone = "${var.region}a"
instance_type = "t3.xlarge"
instance_type = split(": ", "${var.instance_type}")[1]

user_data = data.coder_workspace.me.transition == "start" ? local.user_data_start : local.user_data_end
tags = {
Expand Down
18 changes: 17 additions & 1 deletion examples/templates/aws-windows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ variable "region" {
}
}

variable "instance_type" {
description = "What instance type should your workspace use?"
default = "2C/1G: t3.micro"
validation {
condition = contains([
"2C/1G: t3.micro",
"2C/2G: t3.small",
"2C/4G: t3.medium",
"2C/8G: t3.large",
"4C/16G: t3.xlarge",
"8C/32G: t3.2xlarge",
], var.instance_type)
error_message = "Invalid instance type!"
}
}

provider "aws" {
region = var.region
}
Expand Down Expand Up @@ -83,7 +99,7 @@ EOT
resource "aws_instance" "dev" {
ami = data.aws_ami.windows.id
availability_zone = "${var.region}a"
instance_type = "t3.micro"
instance_type = split(": ", "${var.instance_type}")[1]
count = 1

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