Skip to content

example: add a bare/custom template #2965

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

Merged
merged 6 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
example: add a bare/custom template example
  • Loading branch information
bpmct committed Jul 19, 2022
commit 935f99ffeed283110713898653ba7466685f122e
7 changes: 7 additions & 0 deletions examples/templates/bare/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Bare (custom template)
description: Use this template as a starting point for writing custom templates with Terraform
tags: [bare]
---

See <https://coder.com/docs/coder-oss/latest/templates#creating--troubleshooting-templates>
50 changes: 50 additions & 0 deletions examples/templates/bare/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
terraform {
required_providers {
coder = {
source = "coder/coder"
}
}
}

# This example does not provision any resources. Use this
# template as a starting point for writing custom templates
# using any Terraform resource/provider.
#
# see: https://coder.com/docs/coder-oss/latest/templates

data "coder_workspace" "me" {

}

resource "coder_agent" "dev1" {
os = "linux"
arch = "amd64"
auth = "token"
}

resource "null_resource" "fake-compute" {
# When a workspace is stopped, this resource is destroyed.
count = data.coder_workspace.me.transition == "start" ? 1 : 0

provisioner "local-exec" {
command = "echo 🔊 ${data.coder_workspace.me.owner} has started a workspace named ${data.coder_workspace.me.name}"
}

# Run the Coder agent init script on resources
# to access web apps and SSH:
#
# ${coder_agent.dev1.init_script}
}

resource "null_resource" "fake-disk" {
# This resource will remain even when workspaces are restarted
count = 1
}

resource "coder_app" "fake-app" {
# Access :8080 in the workspace from the Coder dashboard
name = "VS Code"
icon = "/icon/code.svg"
agent_id = "fake-compute"
url = "http://localhost:8080"
}