Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ec1e8f

Browse files
authored
example: aws-linux: resize and use non-root user (#2186)
1 parent92db80c commit0ec1e8f

File tree

1 file changed

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

1 file changed

+11
-15
lines changed

‎examples/templates/aws-linux/main.tf

Lines changed: 11 additions & 15 deletions
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:${local.linux_user}
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 -uubuntu sh -c '${coder_agent.dev.init_script}'
96+
sudo -u${local.linux_user} sh -c '${coder_agent.dev.init_script}'
10597
--//--
10698
EOT
10799

@@ -129,12 +121,16 @@ Content-Disposition: attachment; filename="userdata.txt"
129121
sudo shutdown -h now
130122
--//--
131123
EOT
124+
125+
# Ensure Coder username is a valid Linux username
126+
linux_user=lower(substr(data.coder_workspace.me.owner,0,32))
127+
132128
}
133129

134130
resource"aws_instance""dev" {
135131
ami=data.aws_ami.ubuntu.id
136132
availability_zone="${var.region}a"
137-
instance_type="t3.micro"
133+
instance_type="t3.xlarge"
138134

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp