-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,19 +36,6 @@ variable "region" { | |
} | ||
} | ||
|
||
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." | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = var.region | ||
} | ||
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 commentThe 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 |
||
sudo: ALL=(ALL) NOPASSWD:ALL | ||
shell: /bin/bash | ||
|
||
--// | ||
Content-Type: text/x-shellscript; charset="us-ascii" | ||
|
@@ -101,7 +93,7 @@ Content-Transfer-Encoding: 7bit | |
Content-Disposition: attachment; filename="userdata.txt" | ||
|
||
#!/bin/bash | ||
sudo -u ubuntu sh -c '${coder_agent.dev.init_script}' | ||
sudo -u ${lower(data.coder_workspace.me.owner)} sh -c '${coder_agent.dev.init_script}' | ||
--//-- | ||
EOT | ||
|
||
|
@@ -134,7 +126,7 @@ EOT | |
resource "aws_instance" "dev" { | ||
ami = data.aws_ami.ubuntu.id | ||
availability_zone = "${var.region}a" | ||
instance_type = "t3.micro" | ||
instance_type = "t3.medium" | ||
bpmct marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
user_data = data.coder_workspace.me.transition == "start" ? local.user_data_start : local.user_data_end | ||
tags = { | ||
|
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