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

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

    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",
        },
    });
    
    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",
        })
    
    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
    	})
    }
    
    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" },
            },
        });
    
    });
    
    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());
    
        }
    }
    
    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
    

    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>
    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]
    func GetWorkspacePreset(ctx *Context, args *GetWorkspacePresetArgs, opts ...InvokeOption) (*GetWorkspacePresetResult, error)
    func GetWorkspacePresetOutput(ctx *Context, args *GetWorkspacePresetOutputArgs, opts ...InvokeOption) GetWorkspacePresetResultOutput

    > 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)
    }
    public static CompletableFuture<GetWorkspacePresetResult> getWorkspacePreset(GetWorkspacePresetArgs args, InvokeOptions options)
    public static Output<GetWorkspacePresetResult> getWorkspacePreset(GetWorkspacePresetArgs args, InvokeOptions options)
    
    fn::invoke:
      function: coder:index/getWorkspacePreset:getWorkspacePreset
      arguments:
        # arguments dictionary

    The following arguments are supported:

    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.
    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.
    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.
    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.
    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.
    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.

    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 double
    The number of workspaces to keep in reserve for this preset.
    Instances float64
    The number of workspaces to keep in reserve for this preset.
    instances Double
    The number of workspaces to keep in reserve for this preset.
    instances number
    The number of workspaces to keep in reserve for this preset.
    instances float
    The number of workspaces to keep in reserve for this preset.
    instances 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.
    coder logo
    coder 2.4.0-pre1 published on Tuesday, Apr 15, 2025 by coder