coder.Metadata
Explore with Pulumi AI
Use this resource to attach metadata to a resource. They will be displayed in the Coder dashboard alongside the resource. The resource containing the agent, and it’s metadata, will be shown by default.
Alternatively, to attach metadata to the agent, use a metadata
block within a coder.Agent
resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as coder from "@pulumi/coder";
import * as kubernetes from "@pulumi/kubernetes";
import * as tls from "@pulumi/tls";
export = async () => {
const me = await coder.getWorkspace({});
const dev: kubernetes.index.Kubernetes_pod[] = [];
for (const range = {value: 0}; range.value < me.startCount; range.value++) {
dev.push(new kubernetes.index.Kubernetes_pod(`dev-${range.value}`, {
metadata: [{
name: "k8s_example",
namespace: "example",
}],
spec: [{}],
}));
}
const exampleKeyPair = new tls.index.Tls_private_key("exampleKeyPair", {
algorithm: "ECDSA",
ecdsaCurve: "P256",
});
const podInfo: coder.Metadata[] = [];
for (const range = {value: 0}; range.value < me.startCount; range.value++) {
podInfo.push(new coder.Metadata(`podInfo-${range.value}`, {
resourceId: dev[0].id,
dailyCost: 200,
items: [
{
key: "description",
value: "This description will show up in the Coder dashboard.",
},
{
key: "pod_uid",
value: dev[0].uid,
},
{
key: "public_key",
value: exampleKeyPair.publicKeyOpenssh,
sensitive: true,
},
],
}));
}
}
import pulumi
import pulumi_coder as coder
import pulumi_kubernetes as kubernetes
import pulumi_tls as tls
me = coder.get_workspace()
dev = []
for range in [{"value": i} for i in range(0, me.start_count)]:
dev.append(kubernetes.index.Kubernetes_pod(f"dev-{range['value']}",
metadata=[{
name: k8s_example,
namespace: example,
}],
spec=[{}]))
example_key_pair = tls.index.Tls_private_key("exampleKeyPair",
algorithm=ECDSA,
ecdsa_curve=P256)
pod_info = []
for range in [{"value": i} for i in range(0, me.start_count)]:
pod_info.append(coder.Metadata(f"podInfo-{range['value']}",
resource_id=dev[0]["id"],
daily_cost=200,
items=[
{
"key": "description",
"value": "This description will show up in the Coder dashboard.",
},
{
"key": "pod_uid",
"value": dev[0]["uid"],
},
{
"key": "public_key",
"value": example_key_pair["publicKeyOpenssh"],
"sensitive": True,
},
]))
package main
import (
"github.com/pulumi/pulumi-kubernetes/sdk/go/kubernetes"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/coder/v2/coder"
"github.com/pulumi/pulumi-tls/sdk/go/tls"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
me, err := coder.GetWorkspace(ctx, map[string]interface{}{}, nil)
if err != nil {
return err
}
var dev []*kubernetes.Kubernetes_pod
for index := 0; index < me.StartCount; index++ {
key0 := index
_ := index
__res, err := kubernetes.NewKubernetes_pod(ctx, fmt.Sprintf("dev-%v", key0), &kubernetes.Kubernetes_podArgs{
Metadata: []map[string]interface{}{
map[string]interface{}{
"name": "k8s_example",
"namespace": "example",
},
},
Spec: []map[string]interface{}{
map[string]interface{}{},
},
})
if err != nil {
return err
}
dev = append(dev, __res)
}
exampleKeyPair, err := tls.NewTls_private_key(ctx, "exampleKeyPair", &tls.Tls_private_keyArgs{
Algorithm: "ECDSA",
EcdsaCurve: "P256",
})
if err != nil {
return err
}
var podInfo []*coder.Metadata
for index := 0; index < me.StartCount; index++ {
key0 := index
_ := index
__res, err := coder.NewMetadata(ctx, fmt.Sprintf("podInfo-%v", key0), &coder.MetadataArgs{
ResourceId: dev[0].Id,
DailyCost: pulumi.Float64(200),
Items: coder.MetadataItemArray{
&coder.MetadataItemArgs{
Key: pulumi.String("description"),
Value: pulumi.String("This description will show up in the Coder dashboard."),
},
&coder.MetadataItemArgs{
Key: pulumi.String("pod_uid"),
Value: dev[0].Uid,
},
&coder.MetadataItemArgs{
Key: pulumi.String("public_key"),
Value: exampleKeyPair.PublicKeyOpenssh,
Sensitive: pulumi.Bool(true),
},
},
})
if err != nil {
return err
}
podInfo = append(podInfo, __res)
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Pulumi;
using Coder = Pulumi.Coder;
using Kubernetes = Pulumi.Kubernetes;
using Tls = Pulumi.Tls;
return await Deployment.RunAsync(async() =>
{
var me = await Coder.GetWorkspace.InvokeAsync();
var dev = new List<Kubernetes.Index.Kubernetes_pod>();
for (var rangeIndex = 0; rangeIndex < me.StartCount; rangeIndex++)
{
var range = new { Value = rangeIndex };
dev.Add(new Kubernetes.Index.Kubernetes_pod($"dev-{range.Value}", new()
{
Metadata = new[]
{
{
{ "name", "k8s_example" },
{ "namespace", "example" },
},
},
Spec = new[]
{
null,
},
}));
}
var exampleKeyPair = new Tls.Index.Tls_private_key("exampleKeyPair", new()
{
Algorithm = "ECDSA",
EcdsaCurve = "P256",
});
var podInfo = new List<Coder.Metadata>();
for (var rangeIndex = 0; rangeIndex < me.StartCount; rangeIndex++)
{
var range = new { Value = rangeIndex };
podInfo.Add(new Coder.Metadata($"podInfo-{range.Value}", new()
{
ResourceId = dev[0].Id,
DailyCost = 200,
Items = new[]
{
new Coder.Inputs.MetadataItemArgs
{
Key = "description",
Value = "This description will show up in the Coder dashboard.",
},
new Coder.Inputs.MetadataItemArgs
{
Key = "pod_uid",
Value = dev[0].Uid,
},
new Coder.Inputs.MetadataItemArgs
{
Key = "public_key",
Value = exampleKeyPair.PublicKeyOpenssh,
Sensitive = true,
},
},
}));
}
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.coder.CoderFunctions;
import com.pulumi.kubernetes.kubernetes_pod;
import com.pulumi.kubernetes.Kubernetes_podArgs;
import com.pulumi.tls.tls_private_key;
import com.pulumi.tls.Tls_private_keyArgs;
import com.pulumi.coder.Metadata;
import com.pulumi.coder.MetadataArgs;
import com.pulumi.coder.inputs.MetadataItemArgs;
import com.pulumi.codegen.internal.KeyedValue;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var me = CoderFunctions.getWorkspace();
for (var i = 0; i < me.applyValue(getWorkspaceResult -> getWorkspaceResult.startCount()); i++) {
new Kubernetes_pod("dev-" + i, Kubernetes_podArgs.builder()
.metadata(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
.spec()
.build());
}
var exampleKeyPair = new Tls_private_key("exampleKeyPair", Tls_private_keyArgs.builder()
.algorithm("ECDSA")
.ecdsaCurve("P256")
.build());
for (var i = 0; i < me.applyValue(getWorkspaceResult -> getWorkspaceResult.startCount()); i++) {
new Metadata("podInfo-" + i, MetadataArgs.builder()
.resourceId(dev[0].id())
.dailyCost(200)
.items(
MetadataItemArgs.builder()
.key("description")
.value("This description will show up in the Coder dashboard.")
.build(),
MetadataItemArgs.builder()
.key("pod_uid")
.value(dev[0].uid())
.build(),
MetadataItemArgs.builder()
.key("public_key")
.value(exampleKeyPair.publicKeyOpenssh())
.sensitive(true)
.build())
.build());
}
}
}
resources:
dev:
type: kubernetes:kubernetes_pod
properties:
metadata:
- name: k8s_example
namespace: example
spec:
- {}
options: {}
exampleKeyPair:
type: tls:tls_private_key
properties:
algorithm: ECDSA
ecdsaCurve: P256
podInfo:
type: coder:Metadata
properties:
resourceId: ${dev[0].id}
# (Enterprise-only) this resource consumes 200 quota units
dailyCost: 200
items:
- key: description
value: This description will show up in the Coder dashboard.
- key: pod_uid
value: ${dev[0].uid}
- key: public_key
value: ${exampleKeyPair.publicKeyOpenssh}
sensitive: true
options: {}
variables:
me:
fn::invoke:
function: coder:getWorkspace
arguments: {}
Create Metadata Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Metadata(name: string, args: MetadataArgs, opts?: CustomResourceOptions);
@overload
def Metadata(resource_name: str,
args: MetadataArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Metadata(resource_name: str,
opts: Optional[ResourceOptions] = None,
resource_id: Optional[str] = None,
daily_cost: Optional[float] = None,
hide: Optional[bool] = None,
icon: Optional[str] = None,
items: Optional[Sequence[MetadataItemArgs]] = None,
metadata_id: Optional[str] = None)
func NewMetadata(ctx *Context, name string, args MetadataArgs, opts ...ResourceOption) (*Metadata, error)
public Metadata(string name, MetadataArgs args, CustomResourceOptions? opts = null)
public Metadata(String name, MetadataArgs args)
public Metadata(String name, MetadataArgs args, CustomResourceOptions options)
type: coder:Metadata
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args MetadataArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args MetadataArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args MetadataArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args MetadataArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args MetadataArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var metadataResource = new Coder.Metadata("metadataResource", new()
{
ResourceId = "string",
DailyCost = 0,
Hide = false,
Icon = "string",
Items = new[]
{
new Coder.Inputs.MetadataItemArgs
{
Key = "string",
IsNull = false,
Sensitive = false,
Value = "string",
},
},
MetadataId = "string",
});
example, err := coder.NewMetadata(ctx, "metadataResource", &coder.MetadataArgs{
ResourceId: pulumi.String("string"),
DailyCost: pulumi.Float64(0),
Hide: pulumi.Bool(false),
Icon: pulumi.String("string"),
Items: coder.MetadataItemArray{
&coder.MetadataItemArgs{
Key: pulumi.String("string"),
IsNull: pulumi.Bool(false),
Sensitive: pulumi.Bool(false),
Value: pulumi.String("string"),
},
},
MetadataId: pulumi.String("string"),
})
var metadataResource = new Metadata("metadataResource", MetadataArgs.builder()
.resourceId("string")
.dailyCost(0)
.hide(false)
.icon("string")
.items(MetadataItemArgs.builder()
.key("string")
.isNull(false)
.sensitive(false)
.value("string")
.build())
.metadataId("string")
.build());
metadata_resource = coder.Metadata("metadataResource",
resource_id="string",
daily_cost=0,
hide=False,
icon="string",
items=[{
"key": "string",
"is_null": False,
"sensitive": False,
"value": "string",
}],
metadata_id="string")
const metadataResource = new coder.Metadata("metadataResource", {
resourceId: "string",
dailyCost: 0,
hide: false,
icon: "string",
items: [{
key: "string",
isNull: false,
sensitive: false,
value: "string",
}],
metadataId: "string",
});
type: coder:Metadata
properties:
dailyCost: 0
hide: false
icon: string
items:
- isNull: false
key: string
sensitive: false
value: string
metadataId: string
resourceId: string
Metadata Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Metadata resource accepts the following input properties:
- Resource
Id string - The
id
property of another resource that metadata should be attached to. - Daily
Cost double - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- Hide bool
- Hide the resource from the UI.
- Icon string
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - Items
List<Metadata
Item> - Each
item
block defines a single metadata item consisting of a key/value pair. - Metadata
Id string - The ID of this resource.
- Resource
Id string - The
id
property of another resource that metadata should be attached to. - Daily
Cost float64 - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- Hide bool
- Hide the resource from the UI.
- Icon string
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - Items
[]Metadata
Item Args - Each
item
block defines a single metadata item consisting of a key/value pair. - Metadata
Id string - The ID of this resource.
- resource
Id String - The
id
property of another resource that metadata should be attached to. - daily
Cost Double - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- hide Boolean
- Hide the resource from the UI.
- icon String
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - items
List<Metadata
Item> - Each
item
block defines a single metadata item consisting of a key/value pair. - metadata
Id String - The ID of this resource.
- resource
Id string - The
id
property of another resource that metadata should be attached to. - daily
Cost number - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- hide boolean
- Hide the resource from the UI.
- icon string
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - items
Metadata
Item[] - Each
item
block defines a single metadata item consisting of a key/value pair. - metadata
Id string - The ID of this resource.
- resource_
id str - The
id
property of another resource that metadata should be attached to. - daily_
cost float - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- hide bool
- Hide the resource from the UI.
- icon str
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - items
Sequence[Metadata
Item Args] - Each
item
block defines a single metadata item consisting of a key/value pair. - metadata_
id str - The ID of this resource.
- resource
Id String - The
id
property of another resource that metadata should be attached to. - daily
Cost Number - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- hide Boolean
- Hide the resource from the UI.
- icon String
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - items List<Property Map>
- Each
item
block defines a single metadata item consisting of a key/value pair. - metadata
Id String - The ID of this resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the Metadata resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Metadata Resource
Get an existing Metadata resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: MetadataState, opts?: CustomResourceOptions): Metadata
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
daily_cost: Optional[float] = None,
hide: Optional[bool] = None,
icon: Optional[str] = None,
items: Optional[Sequence[MetadataItemArgs]] = None,
metadata_id: Optional[str] = None,
resource_id: Optional[str] = None) -> Metadata
func GetMetadata(ctx *Context, name string, id IDInput, state *MetadataState, opts ...ResourceOption) (*Metadata, error)
public static Metadata Get(string name, Input<string> id, MetadataState? state, CustomResourceOptions? opts = null)
public static Metadata get(String name, Output<String> id, MetadataState state, CustomResourceOptions options)
resources: _: type: coder:Metadata get: id: ${id}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Daily
Cost double - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- Hide bool
- Hide the resource from the UI.
- Icon string
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - Items
List<Metadata
Item> - Each
item
block defines a single metadata item consisting of a key/value pair. - Metadata
Id string - The ID of this resource.
- Resource
Id string - The
id
property of another resource that metadata should be attached to.
- Daily
Cost float64 - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- Hide bool
- Hide the resource from the UI.
- Icon string
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - Items
[]Metadata
Item Args - Each
item
block defines a single metadata item consisting of a key/value pair. - Metadata
Id string - The ID of this resource.
- Resource
Id string - The
id
property of another resource that metadata should be attached to.
- daily
Cost Double - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- hide Boolean
- Hide the resource from the UI.
- icon String
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - items
List<Metadata
Item> - Each
item
block defines a single metadata item consisting of a key/value pair. - metadata
Id String - The ID of this resource.
- resource
Id String - The
id
property of another resource that metadata should be attached to.
- daily
Cost number - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- hide boolean
- Hide the resource from the UI.
- icon string
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - items
Metadata
Item[] - Each
item
block defines a single metadata item consisting of a key/value pair. - metadata
Id string - The ID of this resource.
- resource
Id string - The
id
property of another resource that metadata should be attached to.
- daily_
cost float - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- hide bool
- Hide the resource from the UI.
- icon str
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - items
Sequence[Metadata
Item Args] - Each
item
block defines a single metadata item consisting of a key/value pair. - metadata_
id str - The ID of this resource.
- resource_
id str - The
id
property of another resource that metadata should be attached to.
- daily
Cost Number - (Enterprise) The cost of this resource every 24 hours. Use the smallest denomination of your preferred currency. For example, if you work in USD, use cents.
- hide Boolean
- Hide the resource from the UI.
- icon String
- A URL to an icon that will display in the dashboard. View built-in icons here. Use a built-in icon with
"${data.coder_workspace.me.access_url}/icon/<path>"
. - items List<Property Map>
- Each
item
block defines a single metadata item consisting of a key/value pair. - metadata
Id String - The ID of this resource.
- resource
Id String - The
id
property of another resource that metadata should be attached to.
Supporting Types
MetadataItem, MetadataItemArgs
- Key string
- The key of this metadata item.
- Is
Null bool - Sensitive bool
- Set to
true
to for items such as API keys whose values should be hidden from view by default. Note that this does not prevent metadata from being retrieved using the API, so it is not suitable for secrets that should not be exposed to workspace users. - Value string
- The value of this metadata item. Supports basic Markdown, including hyperlinks.
- Key string
- The key of this metadata item.
- Is
Null bool - Sensitive bool
- Set to
true
to for items such as API keys whose values should be hidden from view by default. Note that this does not prevent metadata from being retrieved using the API, so it is not suitable for secrets that should not be exposed to workspace users. - Value string
- The value of this metadata item. Supports basic Markdown, including hyperlinks.
- key String
- The key of this metadata item.
- is
Null Boolean - sensitive Boolean
- Set to
true
to for items such as API keys whose values should be hidden from view by default. Note that this does not prevent metadata from being retrieved using the API, so it is not suitable for secrets that should not be exposed to workspace users. - value String
- The value of this metadata item. Supports basic Markdown, including hyperlinks.
- key string
- The key of this metadata item.
- is
Null boolean - sensitive boolean
- Set to
true
to for items such as API keys whose values should be hidden from view by default. Note that this does not prevent metadata from being retrieved using the API, so it is not suitable for secrets that should not be exposed to workspace users. - value string
- The value of this metadata item. Supports basic Markdown, including hyperlinks.
- key str
- The key of this metadata item.
- is_
null bool - sensitive bool
- Set to
true
to for items such as API keys whose values should be hidden from view by default. Note that this does not prevent metadata from being retrieved using the API, so it is not suitable for secrets that should not be exposed to workspace users. - value str
- The value of this metadata item. Supports basic Markdown, including hyperlinks.
- key String
- The key of this metadata item.
- is
Null Boolean - sensitive Boolean
- Set to
true
to for items such as API keys whose values should be hidden from view by default. Note that this does not prevent metadata from being retrieved using the API, so it is not suitable for secrets that should not be exposed to workspace users. - value String
- The value of this metadata item. Supports basic Markdown, including hyperlinks.
Package Details
- Repository
- coder coder/terraform-provider-coder
- License
- Notes
- This Pulumi package is based on the
coder
Terraform Provider.