-
Notifications
You must be signed in to change notification settings - Fork 885
example: aws-linux: resize and use non-root user #2186
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
Conversation
variable "disk_size" { | ||
description = "Specify your disk size (GiBs)" | ||
default = "20" | ||
type = number | ||
validation { | ||
condition = ( | ||
var.disk_size >= 8 && | ||
var.disk_size <= 256 | ||
) | ||
error_message = "Disk size must be between 8 and 256." | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was never used
examples/templates/aws-linux/main.tf
Outdated
@@ -93,6 +80,11 @@ Content-Disposition: attachment; filename="cloud-config.txt" | |||
#cloud-config | |||
cloud_final_modules: | |||
- [scripts-user, always] | |||
hostname: ${lower(data.coder_workspace.me.name)} | |||
users: | |||
- name: ${lower(data.coder_workspace.me.owner)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what restrictions do we have on coder usernames? Is it a subset of the valid Linux usernames?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually not sure here. I could change it to "coder" to be safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so a little googling: Linux usernames can have uppercase, lowercase, digits, hyphens and underscores -- we restrict our usernames to this minus the hyphens, so all good on character set. However, Linux usernames can only be 32 characters long, at least in some flavors/system utilities and we allow unlimited. I think it's fine to just truncate if the name is too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for looking into this. Usernames are now truncated, if longer than 32 characters using Terraform's substr
. If usernames are shorter, nothing happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This runs the aws-linux template as a non-root user and resizes to support JetBrains Gateway.
50% of the way there for #2179.
code-server support is trivial (I have done it in https://github.com/bpmct/coder-templates/tree/main/aws-spot), but we need to host the IDE icon statically as well, like this example: https://registry.terraform.io/providers/coder/coder/latest/docs/resources/app#example-usage