-
Notifications
You must be signed in to change notification settings - Fork 53
feat: add template for externally managed workspaces to coder-labs #343
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
Draft
kacpersaw
wants to merge
4
commits into
main
Choose a base branch
from
kacpersaw/externally-managed-workspace
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+88
−0
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6223569
feat: add template for externally managed workspaces to coder-labs
kacpersaw b6ca074
Merge branch 'main' into kacpersaw/externally-managed-workspace
kacpersaw 1d777eb
Apply review suggestions, use coder_parameter for agent OS & ARCH
kacpersaw 87dc79d
Fix fmt
kacpersaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions
13
registry/coder-labs/templates/externally-managed-workspace/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
74 changes: 74 additions & 0 deletions
74
registry/coder-labs/templates/externally-managed-workspace/main.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.