1. Packages
  2. Coder Provider
  3. API Docs
  4. getWorkspaceTags
coder 2.4.0-pre1 published on Tuesday, Apr 15, 2025 by coder

coder.getWorkspaceTags

Explore with Pulumi AI

coder 2.4.0-pre1 published on Tuesday, Apr 15, 2025 by coder

Use this data source to configure workspace tags to select provisioners.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as coder from "@pulumi/coder";

const osSelector = coder.getParameter({
    name: "os_selector",
    displayName: "Operating System",
    mutable: false,
    "default": "osx",
    options: [
        {
            icon: "/icons/linux.png",
            name: "Linux",
            value: "linux",
        },
        {
            icon: "/icons/osx.png",
            name: "OSX",
            value: "osx",
        },
        {
            icon: "/icons/windows.png",
            name: "Windows",
            value: "windows",
        },
    ],
});
const featureCacheEnabled = coder.getParameter({
    name: "feature_cache_enabled",
    displayName: "Enable cache?",
    type: "bool",
    "default": "false",
});
const featureDebugEnabled = coder.getParameter({
    name: "feature_debug_enabled",
    displayName: "Enable debug?",
    type: "bool",
    "default": "true",
});
const customWorkspaceTags = Promise.all([osSelector, featureDebugEnabled, featureCacheEnabled]).then(([osSelector, featureDebugEnabled, featureCacheEnabled]) => coder.getWorkspaceTags({
    tags: {
        cluster: "developers",
        os: osSelector.value,
        debug: `${featureDebugEnabled.value}+12345`,
        cache: featureCacheEnabled.value == "true" ? "nix-with-cache" : "no-cache",
    },
}));
Copy
import pulumi
import pulumi_coder as coder

os_selector = coder.get_parameter(name="os_selector",
    display_name="Operating System",
    mutable=False,
    default="osx",
    options=[
        {
            "icon": "/icons/linux.png",
            "name": "Linux",
            "value": "linux",
        },
        {
            "icon": "/icons/osx.png",
            "name": "OSX",
            "value": "osx",
        },
        {
            "icon": "/icons/windows.png",
            "name": "Windows",
            "value": "windows",
        },
    ])
feature_cache_enabled = coder.get_parameter(name="feature_cache_enabled",
    display_name="Enable cache?",
    type="bool",
    default="false")
feature_debug_enabled = coder.get_parameter(name="feature_debug_enabled",
    display_name="Enable debug?",
    type="bool",
    default="true")
custom_workspace_tags = coder.get_workspace_tags(tags={
    "cluster": "developers",
    "os": os_selector.value,
    "debug": f"{feature_debug_enabled.value}+12345",
    "cache": "nix-with-cache" if feature_cache_enabled.value == "true" else "no-cache",
})
Copy
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-terraform-provider/sdks/go/coder/v2/coder"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		osSelector, err := coder.GetParameter(ctx, &coder.GetParameterArgs{
			Name:        "os_selector",
			DisplayName: pulumi.StringRef("Operating System"),
			Mutable:     pulumi.BoolRef(false),
			Default:     pulumi.StringRef("osx"),
			Options: []coder.GetParameterOption{
				{
					Icon:  pulumi.StringRef("/icons/linux.png"),
					Name:  "Linux",
					Value: "linux",
				},
				{
					Icon:  pulumi.StringRef("/icons/osx.png"),
					Name:  "OSX",
					Value: "osx",
				},
				{
					Icon:  pulumi.StringRef("/icons/windows.png"),
					Name:  "Windows",
					Value: "windows",
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		featureCacheEnabled, err := coder.GetParameter(ctx, &coder.GetParameterArgs{
			Name:        "feature_cache_enabled",
			DisplayName: pulumi.StringRef("Enable cache?"),
			Type:        pulumi.StringRef("bool"),
			Default:     pulumi.StringRef("false"),
		}, nil)
		if err != nil {
			return err
		}
		featureDebugEnabled, err := coder.GetParameter(ctx, &coder.GetParameterArgs{
			Name:        "feature_debug_enabled",
			DisplayName: pulumi.StringRef("Enable debug?"),
			Type:        pulumi.StringRef("bool"),
			Default:     pulumi.StringRef("true"),
		}, nil)
		if err != nil {
			return err
		}
		var tmp0 string
		if featureCacheEnabled.Value == "true" {
			tmp0 = "nix-with-cache"
		} else {
			tmp0 = "no-cache"
		}
		_, err = coder.GetWorkspaceTags(ctx, &coder.GetWorkspaceTagsArgs{
			Tags: pulumi.StringMap{
				"cluster": "developers",
				"os":      osSelector.Value,
				"debug":   fmt.Sprintf("%v+12345", featureDebugEnabled.Value),
				"cache":   tmp0,
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Coder = Pulumi.Coder;

return await Deployment.RunAsync(() => 
{
    var osSelector = Coder.GetParameter.Invoke(new()
    {
        Name = "os_selector",
        DisplayName = "Operating System",
        Mutable = false,
        Default = "osx",
        Options = new[]
        {
            new Coder.Inputs.GetParameterOptionInputArgs
            {
                Icon = "/icons/linux.png",
                Name = "Linux",
                Value = "linux",
            },
            new Coder.Inputs.GetParameterOptionInputArgs
            {
                Icon = "/icons/osx.png",
                Name = "OSX",
                Value = "osx",
            },
            new Coder.Inputs.GetParameterOptionInputArgs
            {
                Icon = "/icons/windows.png",
                Name = "Windows",
                Value = "windows",
            },
        },
    });

    var featureCacheEnabled = Coder.GetParameter.Invoke(new()
    {
        Name = "feature_cache_enabled",
        DisplayName = "Enable cache?",
        Type = "bool",
        Default = "false",
    });

    var featureDebugEnabled = Coder.GetParameter.Invoke(new()
    {
        Name = "feature_debug_enabled",
        DisplayName = "Enable debug?",
        Type = "bool",
        Default = "true",
    });

    var customWorkspaceTags = Coder.GetWorkspaceTags.Invoke(new()
    {
        Tags = 
        {
            { "cluster", "developers" },
            { "os", osSelector.Apply(getParameterResult => getParameterResult.Value) },
            { "debug", $"{featureDebugEnabled.Apply(getParameterResult => getParameterResult.Value)}+12345" },
            { "cache", featureCacheEnabled.Apply(getParameterResult => getParameterResult.Value) == "true" ? "nix-with-cache" : "no-cache" },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.coder.CoderFunctions;
import com.pulumi.coder.inputs.GetParameterArgs;
import com.pulumi.coder.inputs.GetWorkspaceTagsArgs;
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 osSelector = CoderFunctions.getParameter(GetParameterArgs.builder()
            .name("os_selector")
            .displayName("Operating System")
            .mutable(false)
            .default_("osx")
            .options(            
                GetParameterOptionArgs.builder()
                    .icon("/icons/linux.png")
                    .name("Linux")
                    .value("linux")
                    .build(),
                GetParameterOptionArgs.builder()
                    .icon("/icons/osx.png")
                    .name("OSX")
                    .value("osx")
                    .build(),
                GetParameterOptionArgs.builder()
                    .icon("/icons/windows.png")
                    .name("Windows")
                    .value("windows")
                    .build())
            .build());

        final var featureCacheEnabled = CoderFunctions.getParameter(GetParameterArgs.builder()
            .name("feature_cache_enabled")
            .displayName("Enable cache?")
            .type("bool")
            .default_(false)
            .build());

        final var featureDebugEnabled = CoderFunctions.getParameter(GetParameterArgs.builder()
            .name("feature_debug_enabled")
            .displayName("Enable debug?")
            .type("bool")
            .default_(true)
            .build());

        final var customWorkspaceTags = CoderFunctions.getWorkspaceTags(GetWorkspaceTagsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("cluster", "developers"),
                Map.entry("os", osSelector.applyValue(getParameterResult -> getParameterResult.value())),
                Map.entry("debug", String.format("%s+12345", featureDebugEnabled.applyValue(getParameterResult -> getParameterResult.value()))),
                Map.entry("cache", featureCacheEnabled.applyValue(getParameterResult -> getParameterResult.value()) == "true" ? "nix-with-cache" : "no-cache")
            ))
            .build());

    }
}
Copy
Coming soon!

Using getWorkspaceTags

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getWorkspaceTags(args: GetWorkspaceTagsArgs, opts?: InvokeOptions): Promise<GetWorkspaceTagsResult>
function getWorkspaceTagsOutput(args: GetWorkspaceTagsOutputArgs, opts?: InvokeOptions): Output<GetWorkspaceTagsResult>
Copy
def get_workspace_tags(id: Optional[str] = None,
                       tags: Optional[Mapping[str, str]] = None,
                       opts: Optional[InvokeOptions] = None) -> GetWorkspaceTagsResult
def get_workspace_tags_output(id: Optional[pulumi.Input[str]] = None,
                       tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetWorkspaceTagsResult]
Copy
func GetWorkspaceTags(ctx *Context, args *GetWorkspaceTagsArgs, opts ...InvokeOption) (*GetWorkspaceTagsResult, error)
func GetWorkspaceTagsOutput(ctx *Context, args *GetWorkspaceTagsOutputArgs, opts ...InvokeOption) GetWorkspaceTagsResultOutput
Copy

> Note: This function is named GetWorkspaceTags in the Go SDK.

public static class GetWorkspaceTags 
{
    public static Task<GetWorkspaceTagsResult> InvokeAsync(GetWorkspaceTagsArgs args, InvokeOptions? opts = null)
    public static Output<GetWorkspaceTagsResult> Invoke(GetWorkspaceTagsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetWorkspaceTagsResult> getWorkspaceTags(GetWorkspaceTagsArgs args, InvokeOptions options)
public static Output<GetWorkspaceTagsResult> getWorkspaceTags(GetWorkspaceTagsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: coder:index/getWorkspaceTags:getWorkspaceTags
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Id string
The ID of this resource.
Tags Dictionary<string, string>
Key-value map with workspace tags
Id string
The ID of this resource.
Tags map[string]string
Key-value map with workspace tags
id String
The ID of this resource.
tags Map<String,String>
Key-value map with workspace tags
id string
The ID of this resource.
tags {[key: string]: string}
Key-value map with workspace tags
id str
The ID of this resource.
tags Mapping[str, str]
Key-value map with workspace tags
id String
The ID of this resource.
tags Map<String>
Key-value map with workspace tags

getWorkspaceTags Result

The following output properties are available:

Id string
The ID of this resource.
Tags Dictionary<string, string>
Key-value map with workspace tags
Id string
The ID of this resource.
Tags map[string]string
Key-value map with workspace tags
id String
The ID of this resource.
tags Map<String,String>
Key-value map with workspace tags
id string
The ID of this resource.
tags {[key: string]: string}
Key-value map with workspace tags
id str
The ID of this resource.
tags Mapping[str, str]
Key-value map with workspace tags
id String
The ID of this resource.
tags Map<String>
Key-value map with workspace tags

Package Details

Repository
coder coder/terraform-provider-coder
License
Notes
This Pulumi package is based on the coder Terraform Provider.
coder 2.4.0-pre1 published on Tuesday, Apr 15, 2025 by coder