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

coder.getWorkspacePreset

Explore with Pulumi AI

Use this data source to predefine common configurations for coder workspaces. Users will have the option to select a defined preset, which will automatically apply the selected configuration. Any parameters defined in the preset will be applied to the workspace. Parameters that are not defined by the preset will still be configurable when creating a workspace.

Example Usage

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

const example = coder.getWorkspacePreset({
    name: "example",
    parameters: {
        [data.coder_parameter.example.name]: "us-central1-a",
        [data.coder_parameter.ami.name]: "ami-xxxxxxxx",
    },
});
Copy
import pulumi
import pulumi_coder as coder

example = coder.get_workspace_preset(name="example",
    parameters={
        data["coder_parameter"]["example"]["name"]: "us-central1-a",
        data["coder_parameter"]["ami"]["name"]: "ami-xxxxxxxx",
    })
Copy
package main

import (
	"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 {
		_, err := coder.GetWorkspacePreset(ctx, &coder.GetWorkspacePresetArgs{
			Name: "example",
			Parameters: map[string]string{
				data.Coder_parameter.Example.Name: "us-central1-a",
				data.Coder_parameter.Ami.Name:     "ami-xxxxxxxx",
			},
		}, 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 example = Coder.GetWorkspacePreset.Invoke(new()
    {
        Name = "example",
        Parameters = 
        {
            { data.Coder_parameter.Example.Name, "us-central1-a" },
            { data.Coder_parameter.Ami.Name, "ami-xxxxxxxx" },
        },
    });

});
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.GetWorkspacePresetArgs;
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 example = CoderFunctions.getWorkspacePreset(GetWorkspacePresetArgs.builder()
            .name("example")
            .parameters(Map.ofEntries(
                Map.entry(data.coder_parameter().example().name(), "us-central1-a"),
                Map.entry(data.coder_parameter().ami().name(), "ami-xxxxxxxx")
            ))
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: coder:getWorkspacePreset
      arguments:
        name: example
        parameters:
          ${data.coder_parameter.example.name}: us-central1-a
          ${data.coder_parameter.ami.name}: ami-xxxxxxxx
Copy

Using getWorkspacePreset

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 getWorkspacePreset(args: GetWorkspacePresetArgs, opts?: InvokeOptions): Promise<GetWorkspacePresetResult>
function getWorkspacePresetOutput(args: GetWorkspacePresetOutputArgs, opts?: InvokeOptions): Output<GetWorkspacePresetResult>
Copy
def get_workspace_preset(name: Optional[str] = None,
                         parameters: Optional[Mapping[str, str]] = None,
                         prebuilds: Optional[GetWorkspacePresetPrebuilds] = None,
                         opts: Optional[InvokeOptions] = None) -> GetWorkspacePresetResult
def get_workspace_preset_output(name: Optional[pulumi.Input[str]] = None,
                         parameters: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                         prebuilds: Optional[pulumi.Input[GetWorkspacePresetPrebuildsArgs]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetWorkspacePresetResult]
Copy
func GetWorkspacePreset(ctx *Context, args *GetWorkspacePresetArgs, opts ...InvokeOption) (*GetWorkspacePresetResult, error)
func GetWorkspacePresetOutput(ctx *Context, args *GetWorkspacePresetOutputArgs, opts ...InvokeOption) GetWorkspacePresetResultOutput
Copy

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

public static class GetWorkspacePreset 
{
    public static Task<GetWorkspacePresetResult> InvokeAsync(GetWorkspacePresetArgs args, InvokeOptions? opts = null)
    public static Output<GetWorkspacePresetResult> Invoke(GetWorkspacePresetInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetWorkspacePresetResult> getWorkspacePreset(GetWorkspacePresetArgs args, InvokeOptions options)
public static Output<GetWorkspacePresetResult> getWorkspacePreset(GetWorkspacePresetArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: coder:index/getWorkspacePreset:getWorkspacePreset
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Name This property is required. string
The name of the workspace preset.
Parameters Dictionary<string, string>
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
Prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
Name This property is required. string
The name of the workspace preset.
Parameters map[string]string
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
Prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
name This property is required. String
The name of the workspace preset.
parameters Map<String,String>
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
name This property is required. string
The name of the workspace preset.
parameters {[key: string]: string}
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
name This property is required. str
The name of the workspace preset.
parameters Mapping[str, str]
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
name This property is required. String
The name of the workspace preset.
parameters Map<String>
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
prebuilds Property Map
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.

getWorkspacePreset Result

The following output properties are available:

Id string
The preset ID is automatically generated and may change between runs. It is recommended to use the name attribute to identify the preset.
Name string
The name of the workspace preset.
Parameters Dictionary<string, string>
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
Prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
Id string
The preset ID is automatically generated and may change between runs. It is recommended to use the name attribute to identify the preset.
Name string
The name of the workspace preset.
Parameters map[string]string
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
Prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
id String
The preset ID is automatically generated and may change between runs. It is recommended to use the name attribute to identify the preset.
name String
The name of the workspace preset.
parameters Map<String,String>
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
id string
The preset ID is automatically generated and may change between runs. It is recommended to use the name attribute to identify the preset.
name string
The name of the workspace preset.
parameters {[key: string]: string}
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
id str
The preset ID is automatically generated and may change between runs. It is recommended to use the name attribute to identify the preset.
name str
The name of the workspace preset.
parameters Mapping[str, str]
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
prebuilds GetWorkspacePresetPrebuilds
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.
id String
The preset ID is automatically generated and may change between runs. It is recommended to use the name attribute to identify the preset.
name String
The name of the workspace preset.
parameters Map<String>
Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
prebuilds Property Map
Prebuilt workspace configuration related to this workspace preset. Coder will build and maintain workspaces in reserve based on this configuration. When a user creates a new workspace using a preset, they will be assigned a prebuilt workspace, instead of waiting for a new workspace to build.

Supporting Types

GetWorkspacePresetPrebuilds

Instances This property is required. double
The number of workspaces to keep in reserve for this preset.
Instances This property is required. float64
The number of workspaces to keep in reserve for this preset.
instances This property is required. Double
The number of workspaces to keep in reserve for this preset.
instances This property is required. number
The number of workspaces to keep in reserve for this preset.
instances This property is required. float
The number of workspaces to keep in reserve for this preset.
instances This property is required. Number
The number of workspaces to keep in reserve for this preset.

Package Details

Repository
coder coder/terraform-provider-coder
License
Notes
This Pulumi package is based on the coder Terraform Provider.