Skip to content

Resource Metadata + Secrets #2989

Closed
@ammario

Description

@ammario

Problem statement

Developers want to see additional metadata about resources in Coder. This could be an instance type, the number of cores an instance has, or a link to the cloud resource itself (say in a GCP dashboard).

As a developer, I want to see information about my workspace, both information that is dynamic (e.g external IP) and the most relevant aspects of the template (no. CPUs).

Definition of done

We should add arbitrary key/value pairs that allow template authors to expose additional metadata. This should be added in our Terraform Provider, allowing customers to expose arbitrary values from existing resources that are provisioned. The key/value pairs would be available from the CLI and the dashboard.


Implementation notes (@bpmct)

Dashboard (figma):

Nested resources (3)

Template:

resource "null_resource" "about" {}

resource "coder_metadata" "about_info" {
  resource_id = null_resource.about.id
  item {
    key = "type"
    value = null
  }
  item {
    key = "quicklinks"
    value = "[onboarding guide](https://mywiki.com/onboarding), [troubleshooting](https://mywiki.com/troubleshooting)"
  }
}

resource "kubernetes_pod" "main-dev" {
  # ...
}

resource "coder_metadata" "dev_info" {
  resource_id = kubernetes_pod.main-dev.id
  item {
    key = "api_key"
    value = "asdfjkl"
    sensitive: true
  }
}

CLI:

$ coder metadata my-workspace
RESOURCE_NAME      KEY                 VALUE
about              workspace-id        acf2a70d-6347-4b8c
about              quicklinks          [onboarding guide](https://mywiki.com/onboarding), [troubleshooting](https://mywiki.com/troubleshooting)
main-dev           type             kubernetes_pod
main-dev           api_key             (hidden)

Some values are sensitive. Use `coder metadata myworkspace <key>` to fetch individual values.

In the future, perhaps resource_id = "global" or global = true could be used to display metadata workspace-wide in another panel if the hack is widely used.


Related:

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions