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

Commit3b1ecd3

Browse files
authored
chore: update aws_linux template (#9325)
1 parentd7a788d commit3b1ecd3

File tree

1 file changed

+18
-55
lines changed
  • examples/templates/aws-linux

1 file changed

+18
-55
lines changed

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

Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder={
44
source="coder/coder"
5-
version="~> 0.7.0"
5+
version="~> 0.11.0"
66
}
77
aws={
88
source="hashicorp/aws"
@@ -30,24 +30,24 @@ data "coder_parameter" "region" {
3030
icon="/emojis/1f1f0-1f1f7.png"
3131
}
3232
option {
33-
name="Asia Pacific (Osaka-Local)"
33+
name="Asia Pacific (Osaka)"
3434
value="ap-northeast-3"
35-
icon="/emojis/1f1f0-1f1f7.png"
35+
icon="/emojis/1f1ef-1f1f5.png"
3636
}
3737
option {
3838
name="Asia Pacific (Mumbai)"
3939
value="ap-south-1"
40-
icon="/emojis/1f1f0-1f1f7.png"
40+
icon="/emojis/1f1ee-1f1f3.png"
4141
}
4242
option {
4343
name="Asia Pacific (Singapore)"
4444
value="ap-southeast-1"
45-
icon="/emojis/1f1f0-1f1f7.png"
45+
icon="/emojis/1f1f8-1f1ec.png"
4646
}
4747
option {
4848
name="Asia Pacific (Sydney)"
4949
value="ap-southeast-2"
50-
icon="/emojis/1f1f0-1f1f7.png"
50+
icon="/emojis/1f1e6-1f1fa.png"
5151
}
5252
option {
5353
name="Canada (Central)"
@@ -176,33 +176,21 @@ resource "coder_agent" "main" {
176176
display_name="CPU Usage"
177177
interval=5
178178
timeout=5
179-
script=<<-EOT
180-
#!/bin/bash
181-
set -e
182-
top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}'
183-
EOT
179+
script="coder stat cpu"
184180
}
185181
metadata {
186182
key="memory"
187183
display_name="Memory Usage"
188184
interval=5
189185
timeout=5
190-
script=<<-EOT
191-
#!/bin/bash
192-
set -e
193-
free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }'
194-
EOT
186+
script="coder stat mem"
195187
}
196188
metadata {
197189
key="disk"
198190
display_name="Disk Usage"
199191
interval=600# every 10 minutes
200192
timeout=30# df can take a while on large filesystems
201-
script=<<-EOT
202-
#!/bin/bash
203-
set -e
204-
df /home/coder | awk '$NF=="/"{printf "%s", $5}'
205-
EOT
193+
script="coder stat disk --path $HOME"
206194
}
207195
}
208196

@@ -223,11 +211,9 @@ resource "coder_app" "code-server" {
223211
}
224212

225213
locals {
226-
227-
# User data is used to stop/start AWS instances. See:
228-
# https://github.com/hashicorp/terraform-provider-aws/issues/22
229-
230-
user_data_start=<<EOT
214+
linux_user="coder"# Ensure this user/group does not exist in your VM image
215+
# User data is used to run the init_script
216+
user_data=<<EOT
231217
Content-Type: multipart/mixed; boundary="//"
232218
MIME-Version: 1.0
233219
@@ -256,42 +242,14 @@ Content-Disposition: attachment; filename="userdata.txt"
256242
sudo -u${local.linux_user} sh -c '${coder_agent.main.init_script}'
257243
--//--
258244
EOT
259-
260-
user_data_end=<<EOT
261-
Content-Type: multipart/mixed; boundary="//"
262-
MIME-Version: 1.0
263-
264-
--//
265-
Content-Type: text/cloud-config; charset="us-ascii"
266-
MIME-Version: 1.0
267-
Content-Transfer-Encoding: 7bit
268-
Content-Disposition: attachment; filename="cloud-config.txt"
269-
270-
#cloud-config
271-
cloud_final_modules:
272-
- [scripts-user, always]
273-
274-
--//
275-
Content-Type: text/x-shellscript; charset="us-ascii"
276-
MIME-Version: 1.0
277-
Content-Transfer-Encoding: 7bit
278-
Content-Disposition: attachment; filename="userdata.txt"
279-
280-
#!/bin/bash
281-
sudo shutdown -h now
282-
--//--
283-
EOT
284-
285-
linux_user="coder"# Ensure this user/group does not exist in your VM image
286-
287245
}
288246

289247
resource"aws_instance""dev" {
290248
ami=data.aws_ami.ubuntu.id
291249
availability_zone="${data.coder_parameter.region.value}a"
292250
instance_type=data.coder_parameter.instance_type.value
293251

294-
user_data=data.coder_workspace.me.transition=="start"?local.user_data_start: local.user_data_end
252+
user_data=local.user_data_start
295253
tags={
296254
Name="coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
297255
# Required if you are using our example policy, see template README
@@ -314,3 +272,8 @@ resource "coder_metadata" "workspace_info" {
314272
value="${aws_instance.dev.root_block_device[0].volume_size} GiB"
315273
}
316274
}
275+
276+
resource"aws_ec2_instance_state""dev" {
277+
instance_id=aws_instance.dev.id
278+
state=data.coder_workspace.me.transition=="start"?"running":"stopped"
279+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp