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

coder.Script

Explore with Pulumi AI

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

    Use this resource to run a script from an agent. When multiple scripts are assigned to the same agent, they are executed in parallel.

    Create Script Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Script(name: string, args: ScriptArgs, opts?: CustomResourceOptions);
    @overload
    def Script(resource_name: str,
               args: ScriptArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def Script(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               agent_id: Optional[str] = None,
               display_name: Optional[str] = None,
               script: Optional[str] = None,
               cron: Optional[str] = None,
               icon: Optional[str] = None,
               log_path: Optional[str] = None,
               run_on_start: Optional[bool] = None,
               run_on_stop: Optional[bool] = None,
               script_id: Optional[str] = None,
               start_blocks_login: Optional[bool] = None,
               timeout: Optional[float] = None)
    func NewScript(ctx *Context, name string, args ScriptArgs, opts ...ResourceOption) (*Script, error)
    public Script(string name, ScriptArgs args, CustomResourceOptions? opts = null)
    public Script(String name, ScriptArgs args)
    public Script(String name, ScriptArgs args, CustomResourceOptions options)
    
    type: coder:Script
    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 ScriptArgs
    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 ScriptArgs
    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 ScriptArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ScriptArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ScriptArgs
    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 scriptResource = new Coder.Script("scriptResource", new()
    {
        AgentId = "string",
        DisplayName = "string",
        Script = "string",
        Cron = "string",
        Icon = "string",
        LogPath = "string",
        RunOnStart = false,
        RunOnStop = false,
        ScriptId = "string",
        StartBlocksLogin = false,
        Timeout = 0,
    });
    
    example, err := coder.NewScript(ctx, "scriptResource", &coder.ScriptArgs{
    	AgentId:          pulumi.String("string"),
    	DisplayName:      pulumi.String("string"),
    	Script:           pulumi.String("string"),
    	Cron:             pulumi.String("string"),
    	Icon:             pulumi.String("string"),
    	LogPath:          pulumi.String("string"),
    	RunOnStart:       pulumi.Bool(false),
    	RunOnStop:        pulumi.Bool(false),
    	ScriptId:         pulumi.String("string"),
    	StartBlocksLogin: pulumi.Bool(false),
    	Timeout:          pulumi.Float64(0),
    })
    
    var scriptResource = new Script("scriptResource", ScriptArgs.builder()
        .agentId("string")
        .displayName("string")
        .script("string")
        .cron("string")
        .icon("string")
        .logPath("string")
        .runOnStart(false)
        .runOnStop(false)
        .scriptId("string")
        .startBlocksLogin(false)
        .timeout(0)
        .build());
    
    script_resource = coder.Script("scriptResource",
        agent_id="string",
        display_name="string",
        script="string",
        cron="string",
        icon="string",
        log_path="string",
        run_on_start=False,
        run_on_stop=False,
        script_id="string",
        start_blocks_login=False,
        timeout=0)
    
    const scriptResource = new coder.Script("scriptResource", {
        agentId: "string",
        displayName: "string",
        script: "string",
        cron: "string",
        icon: "string",
        logPath: "string",
        runOnStart: false,
        runOnStop: false,
        scriptId: "string",
        startBlocksLogin: false,
        timeout: 0,
    });
    
    type: coder:Script
    properties:
        agentId: string
        cron: string
        displayName: string
        icon: string
        logPath: string
        runOnStart: false
        runOnStop: false
        script: string
        scriptId: string
        startBlocksLogin: false
        timeout: 0
    

    Script 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 Script resource accepts the following input properties:

    AgentId string
    The id property of a coder.Agent resource to associate with.
    DisplayName string
    The display name of the script to display logs in the dashboard.
    Script string
    The content of the script that will be run.
    Cron string
    The cron schedule to run the script on. This is a cron expression.
    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>".
    LogPath string
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    RunOnStart bool
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    RunOnStop bool
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    ScriptId string
    The ID of this resource.
    StartBlocksLogin bool
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    Timeout double
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    AgentId string
    The id property of a coder.Agent resource to associate with.
    DisplayName string
    The display name of the script to display logs in the dashboard.
    Script string
    The content of the script that will be run.
    Cron string
    The cron schedule to run the script on. This is a cron expression.
    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>".
    LogPath string
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    RunOnStart bool
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    RunOnStop bool
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    ScriptId string
    The ID of this resource.
    StartBlocksLogin bool
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    Timeout float64
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    agentId String
    The id property of a coder.Agent resource to associate with.
    displayName String
    The display name of the script to display logs in the dashboard.
    script String
    The content of the script that will be run.
    cron String
    The cron schedule to run the script on. This is a cron expression.
    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>".
    logPath String
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    runOnStart Boolean
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    runOnStop Boolean
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    scriptId String
    The ID of this resource.
    startBlocksLogin Boolean
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    timeout Double
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    agentId string
    The id property of a coder.Agent resource to associate with.
    displayName string
    The display name of the script to display logs in the dashboard.
    script string
    The content of the script that will be run.
    cron string
    The cron schedule to run the script on. This is a cron expression.
    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>".
    logPath string
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    runOnStart boolean
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    runOnStop boolean
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    scriptId string
    The ID of this resource.
    startBlocksLogin boolean
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    timeout number
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    agent_id str
    The id property of a coder.Agent resource to associate with.
    display_name str
    The display name of the script to display logs in the dashboard.
    script str
    The content of the script that will be run.
    cron str
    The cron schedule to run the script on. This is a cron expression.
    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>".
    log_path str
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    run_on_start bool
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    run_on_stop bool
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    script_id str
    The ID of this resource.
    start_blocks_login bool
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    timeout float
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    agentId String
    The id property of a coder.Agent resource to associate with.
    displayName String
    The display name of the script to display logs in the dashboard.
    script String
    The content of the script that will be run.
    cron String
    The cron schedule to run the script on. This is a cron expression.
    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>".
    logPath String
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    runOnStart Boolean
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    runOnStop Boolean
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    scriptId String
    The ID of this resource.
    startBlocksLogin Boolean
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    timeout Number
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Script 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 Script Resource

    Get an existing Script 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?: ScriptState, opts?: CustomResourceOptions): Script
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            agent_id: Optional[str] = None,
            cron: Optional[str] = None,
            display_name: Optional[str] = None,
            icon: Optional[str] = None,
            log_path: Optional[str] = None,
            run_on_start: Optional[bool] = None,
            run_on_stop: Optional[bool] = None,
            script: Optional[str] = None,
            script_id: Optional[str] = None,
            start_blocks_login: Optional[bool] = None,
            timeout: Optional[float] = None) -> Script
    func GetScript(ctx *Context, name string, id IDInput, state *ScriptState, opts ...ResourceOption) (*Script, error)
    public static Script Get(string name, Input<string> id, ScriptState? state, CustomResourceOptions? opts = null)
    public static Script get(String name, Output<String> id, ScriptState state, CustomResourceOptions options)
    resources:  _:    type: coder:Script    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.
    The following state arguments are supported:
    AgentId string
    The id property of a coder.Agent resource to associate with.
    Cron string
    The cron schedule to run the script on. This is a cron expression.
    DisplayName string
    The display name of the script to display logs in the dashboard.
    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>".
    LogPath string
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    RunOnStart bool
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    RunOnStop bool
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    Script string
    The content of the script that will be run.
    ScriptId string
    The ID of this resource.
    StartBlocksLogin bool
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    Timeout double
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    AgentId string
    The id property of a coder.Agent resource to associate with.
    Cron string
    The cron schedule to run the script on. This is a cron expression.
    DisplayName string
    The display name of the script to display logs in the dashboard.
    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>".
    LogPath string
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    RunOnStart bool
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    RunOnStop bool
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    Script string
    The content of the script that will be run.
    ScriptId string
    The ID of this resource.
    StartBlocksLogin bool
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    Timeout float64
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    agentId String
    The id property of a coder.Agent resource to associate with.
    cron String
    The cron schedule to run the script on. This is a cron expression.
    displayName String
    The display name of the script to display logs in the dashboard.
    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>".
    logPath String
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    runOnStart Boolean
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    runOnStop Boolean
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    script String
    The content of the script that will be run.
    scriptId String
    The ID of this resource.
    startBlocksLogin Boolean
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    timeout Double
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    agentId string
    The id property of a coder.Agent resource to associate with.
    cron string
    The cron schedule to run the script on. This is a cron expression.
    displayName string
    The display name of the script to display logs in the dashboard.
    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>".
    logPath string
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    runOnStart boolean
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    runOnStop boolean
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    script string
    The content of the script that will be run.
    scriptId string
    The ID of this resource.
    startBlocksLogin boolean
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    timeout number
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    agent_id str
    The id property of a coder.Agent resource to associate with.
    cron str
    The cron schedule to run the script on. This is a cron expression.
    display_name str
    The display name of the script to display logs in the dashboard.
    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>".
    log_path str
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    run_on_start bool
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    run_on_stop bool
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    script str
    The content of the script that will be run.
    script_id str
    The ID of this resource.
    start_blocks_login bool
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    timeout float
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.
    agentId String
    The id property of a coder.Agent resource to associate with.
    cron String
    The cron schedule to run the script on. This is a cron expression.
    displayName String
    The display name of the script to display logs in the dashboard.
    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>".
    logPath String
    The path of a file to write the logs to. If relative, it will be appended to tmp.
    runOnStart Boolean
    This option defines whether or not the script should run when the agent starts. The script should exit when it is done to signal that the agent is ready.
    runOnStop Boolean
    This option defines whether or not the script should run when the agent stops. The script should exit when it is done to signal that the workspace can be stopped.
    script String
    The content of the script that will be run.
    scriptId String
    The ID of this resource.
    startBlocksLogin Boolean
    This option determines whether users can log in immediately or must wait for the workspace to finish running this script upon startup. If not enabled, users may encounter an incomplete workspace when logging in. This option only sets the default, the user can still manually override the behavior.
    timeout Number
    Time in seconds that the script is allowed to run. If the script does not complete within this time, the script is terminated and the agent lifecycle status is marked as timed out. A value of zero (default) means no timeout.

    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