Skip to content

Commit b6ad562

Browse files
authored
example: add a bare/custom template (coder#2965)
1 parent a2f6b25 commit b6ad562

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

examples/templates/bare/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Bare (custom template)
3+
description: Use this template as a starting point for writing custom templates with Terraform
4+
tags: [bare]
5+
---
6+
7+
See <https://coder.com/docs/coder-oss/latest/templates#creating--troubleshooting-templates>

examples/templates/bare/main.tf

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
terraform {
2+
required_providers {
3+
coder = {
4+
source = "coder/coder"
5+
}
6+
}
7+
}
8+
9+
# This example does not provision any resources. Use this
10+
# template as a starting point for writing custom templates
11+
# using any Terraform resource/provider.
12+
#
13+
# See: https://coder.com/docs/coder-oss/latest/templates
14+
15+
data "coder_workspace" "me" {
16+
}
17+
18+
resource "coder_agent" "dev1" {
19+
os = "linux"
20+
arch = "amd64"
21+
auth = "token"
22+
}
23+
24+
resource "null_resource" "fake-compute" {
25+
# When a workspace is stopped, this resource is destroyed.
26+
count = data.coder_workspace.me.transition == "start" ? 1 : 0
27+
28+
provisioner "local-exec" {
29+
command = "echo 🔊 ${data.coder_workspace.me.owner} has started a workspace named ${data.coder_workspace.me.name}"
30+
}
31+
32+
# Run the Coder agent init script on resources
33+
# to access web apps and SSH:
34+
#
35+
# export CODER_AGENT_TOKEN=${coder_agent.dev1.token}
36+
# ${coder_agent.dev1.init_script}
37+
}
38+
39+
resource "null_resource" "fake-disk" {
40+
# This resource will remain even when workspaces are restarted.
41+
count = 1
42+
}
43+
44+
resource "coder_app" "fake-app" {
45+
# Access :8080 in the workspace from the Coder dashboard.
46+
name = "VS Code"
47+
icon = "/icon/code.svg"
48+
agent_id = "fake-compute"
49+
url = "http://localhost:8080"
50+
}

0 commit comments

Comments
 (0)