Skip to content

Commit 556fbac

Browse files
committed
example: aws-linux: resize and use non-root user
1 parent a86c957 commit 556fbac

File tree

1 file changed

+7
-15
lines changed
  • examples/templates/aws-linux

1 file changed

+7
-15
lines changed

examples/templates/aws-linux/main.tf

+7-15
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@ variable "region" {
3636
}
3737
}
3838

39-
variable "disk_size" {
40-
description = "Specify your disk size (GiBs)"
41-
default = "20"
42-
type = number
43-
validation {
44-
condition = (
45-
var.disk_size >= 8 &&
46-
var.disk_size <= 256
47-
)
48-
error_message = "Disk size must be between 8 and 256."
49-
}
50-
}
51-
5239
provider "aws" {
5340
region = var.region
5441
}
@@ -93,6 +80,11 @@ Content-Disposition: attachment; filename="cloud-config.txt"
9380
#cloud-config
9481
cloud_final_modules:
9582
- [scripts-user, always]
83+
hostname: ${lower(data.coder_workspace.me.name)}
84+
users:
85+
- name: ${lower(data.coder_workspace.me.owner)}
86+
sudo: ALL=(ALL) NOPASSWD:ALL
87+
shell: /bin/bash
9688
9789
--//
9890
Content-Type: text/x-shellscript; charset="us-ascii"
@@ -101,7 +93,7 @@ Content-Transfer-Encoding: 7bit
10193
Content-Disposition: attachment; filename="userdata.txt"
10294
10395
#!/bin/bash
104-
sudo -u ubuntu sh -c '${coder_agent.dev.init_script}'
96+
sudo -u ${lower(data.coder_workspace.me.owner)} sh -c '${coder_agent.dev.init_script}'
10597
--//--
10698
EOT
10799

@@ -134,7 +126,7 @@ EOT
134126
resource "aws_instance" "dev" {
135127
ami = data.aws_ami.ubuntu.id
136128
availability_zone = "${var.region}a"
137-
instance_type = "t3.micro"
129+
instance_type = "t3.medium"
138130

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

0 commit comments

Comments
 (0)