page_title | subcategory | description |
---|---|---|
coder_workspace Data Source - terraform-provider-coder |
Use this data source to get information for the active workspace build. |
Use this data source to get information for the active workspace build.
provider "coder" {}
provider "docker" {}
data "coder_workspace" "me" {}
data "coder_workspace_owner" "me" {}
resource "coder_agent" "dev" {
arch = "amd64"
os = "linux"
dir = "/workspace"
}
resource "docker_container" "workspace" {
count = data.coder_workspace.me.start_count
image = docker_image.main.name
# Uses lower() to avoid Docker restriction on container names.
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}"
# Hostname makes the shell more user friendly: coder@my-workspace:~$
hostname = data.coder_workspace.me.name
# Use the docker gateway if the access URL is 127.0.0.1
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")]
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
host {
host = "host.docker.internal"
ip = "host-gateway"
}
# Add labels in Docker to keep track of orphan resources.
labels {
label = "coder.owner"
value = data.coder_workspace_owner.me.name
}
labels {
label = "coder.owner_id"
value = data.coder_workspace_owner.me.id
}
labels {
label = "coder.workspace_id"
value = data.coder_workspace.me.id
}
labels {
label = "coder.workspace_name"
value = data.coder_workspace.me.name
}
}
access_port
(Number) The access port of the Coder deployment provisioning this workspace.access_url
(String) The access URL of the Coder deployment provisioning this workspace.id
(String) UUID of the workspace.is_prebuild
(Boolean) Whether the workspace is a prebuild.name
(String) Name of the workspace.prebuild_count
(Number) A computed count, equal to 1 if the workspace was prebuilt.start_count
(Number) A computed count based ontransition
state. Ifstart
, count will equal 1.template_id
(String) ID of the workspace's template.template_name
(String) Name of the workspace's template.template_version
(String) Version of the workspace's template.transition
(String) Eitherstart
orstop
. Use this to start/stop resources withcount
.