Skip to content

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

Merged
merged 3 commits into from
Jun 9, 2022
Merged

Conversation

bpmct
Copy link
Member

@bpmct bpmct commented Jun 8, 2022

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

@bpmct bpmct requested a review from spikecurtis June 8, 2022 20:20
Comment on lines -39 to -50
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."
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this was never used

@@ -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)}
Copy link
Contributor

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?

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'm actually not sure here. I could change it to "coder" to be safe

Copy link
Contributor

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.

Copy link
Member Author

@bpmct bpmct Jun 9, 2022

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

@bpmct bpmct requested a review from spikecurtis June 9, 2022 13:56
Copy link
Contributor

@spikecurtis spikecurtis left a comment

Choose a reason for hiding this comment

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

:shipit:

@bpmct bpmct enabled auto-merge (squash) June 9, 2022 18:00
@bpmct bpmct merged commit 0ec1e8f into main Jun 9, 2022
@bpmct bpmct deleted the bpmct/aws-ec2-user branch June 9, 2022 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants