-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: explain resource metadata (#3447)
- Loading branch information
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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,60 @@ | ||
# Resource Metadata | ||
|
||
Expose key workspace information to your users via [`coder_metadata`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/metadata) resources in your template code. | ||
|
||
![ui](../images/metadata-ui.png) | ||
|
||
<blockquote class="info"> | ||
Coder automatically generates the <code>type</code> metadata. | ||
</blockquote> | ||
|
||
You can use `coder_metadata` to show | ||
|
||
- Compute resources | ||
- IP addresses | ||
- [Secrets](../secrets.md#displaying-secrets) | ||
- Important file paths | ||
|
||
and any other Terraform resource attribute. | ||
|
||
## Example | ||
|
||
Expose the disk size, deployment name, and persistent | ||
directory in a Kubernetes template with: | ||
|
||
```hcl | ||
resource "kubernetes_persistent_volume_claim" "root" { | ||
... | ||
} | ||
resource "kubernetes_deployment" "coder" { | ||
# My deployment is ephemeral | ||
count = data.coder_workspace.me.start_count | ||
... | ||
} | ||
resource "coder_metadata" "pvc" { | ||
resource_id = kubernetes_persistent_volume_claim.root.id | ||
item { | ||
key = "size" | ||
value = kubernetes_persistent_volume_claim.root.spec[0].resources[0].requests.storage | ||
} | ||
item { | ||
key = "dir" | ||
value = "/home/coder" | ||
} | ||
} | ||
resource "coder_metadata" "deployment" { | ||
count = data.coder_workspace.me.start_count | ||
resource_id = kubernetes_deployment.coder[0].id | ||
item { | ||
key = "name" | ||
value = kubernetes_deployment.coder[0].metadata[0].name | ||
} | ||
} | ||
``` | ||
|
||
## Up next | ||
|
||
- Learn about [secrets](../secrets.md) |