feat: add template for externally managed workspaces to coder-labs (#343)
## Description Add externally-managed-workspace template for connecting Coder workspaces to externally provisioned compute resources ## Type of Change - [ ] New module - [ ] Bug fix - [x] Feature/enhancement - [ ] Documentation - [ ] Other ## Testing & Validation - [x] Tests pass (`bun test`) - [x] Code formatted (`bun run fmt`) - [x] Changes tested locally ## Related Issues https://github.com/coder/coder/issues/19091
This commit is contained in:
parent
bc383a32f3
commit
f712d1c55b
1
.icons/electric-plug-emoji.svg
Normal file
1
.icons/electric-plug-emoji.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><text x="50%" y="50%" font-size="96px" text-anchor="middle" dominant-baseline="middle" font-family="Apple Color Emoji, Segoe UI Emoji, Noto Color Emoji, sans-serif">🔌</text></svg>
|
||||||
|
After Width: | Height: | Size: 247 B |
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
display_name: Externally Managed Workspace
|
||||||
|
description: A template to provision externally managed resources as Coder workspaces
|
||||||
|
icon: ../../../../.icons/electric-plug-emoji.svg
|
||||||
|
verified: true
|
||||||
|
tags: [external]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Externally Managed Workspace Template
|
||||||
|
|
||||||
|
This template provides a minimal scaffolding for creating Coder workspaces that connect to externally provisioned compute resources.
|
||||||
|
|
||||||
|
Use this template as a starting point to build your own custom templates for scenarios where you need to connect to existing infrastructure.
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
coder = {
|
||||||
|
source = "coder/coder"
|
||||||
|
version = ">= 2.10"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data "coder_parameter" "agent_config" {
|
||||||
|
name = "agent_config"
|
||||||
|
display_name = "Agent Configuration"
|
||||||
|
description = "Select the operating system and architecture combination for the agent"
|
||||||
|
type = "string"
|
||||||
|
default = "linux-amd64"
|
||||||
|
|
||||||
|
option {
|
||||||
|
name = "Linux AMD64"
|
||||||
|
value = "linux-amd64"
|
||||||
|
}
|
||||||
|
option {
|
||||||
|
name = "Linux ARM64"
|
||||||
|
value = "linux-arm64"
|
||||||
|
}
|
||||||
|
option {
|
||||||
|
name = "Linux ARMv7"
|
||||||
|
value = "linux-armv7"
|
||||||
|
}
|
||||||
|
option {
|
||||||
|
name = "Windows AMD64"
|
||||||
|
value = "windows-amd64"
|
||||||
|
}
|
||||||
|
option {
|
||||||
|
name = "Windows ARM64"
|
||||||
|
value = "windows-arm64"
|
||||||
|
}
|
||||||
|
option {
|
||||||
|
name = "macOS AMD64"
|
||||||
|
value = "darwin-amd64"
|
||||||
|
}
|
||||||
|
option {
|
||||||
|
name = "macOS ARM64 (Apple Silicon)"
|
||||||
|
value = "darwin-arm64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data "coder_workspace" "me" {}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
agent_config = split("-", data.coder_parameter.agent_config.value)
|
||||||
|
agent_os = local.agent_config[0]
|
||||||
|
agent_arch = local.agent_config[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_agent" "main" {
|
||||||
|
arch = local.agent_arch
|
||||||
|
os = local.agent_os
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "coder_external_agent" "main" {
|
||||||
|
agent_id = coder_agent.main.id
|
||||||
|
}
|
||||||
|
|
||||||
|
# Adds code-server
|
||||||
|
# See all available modules at https://registry.coder.com/modules
|
||||||
|
module "code-server" {
|
||||||
|
count = data.coder_workspace.me.start_count
|
||||||
|
source = "registry.coder.com/coder/code-server/coder"
|
||||||
|
|
||||||
|
# This ensures that the latest non-breaking version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
|
||||||
|
version = "~> 1.0"
|
||||||
|
|
||||||
|
agent_id = coder_agent.main.id
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user