1. Packages
  2. Prefect Provider
  3. API Docs
  4. Variable
prefect 2.22.4 published on Wednesday, Mar 26, 2025 by prefecthq

prefect.Variable

Explore with Pulumi AI

The resource variable represents a Prefect Variable. Variables enable you to store and reuse non-sensitive information in your flows. For more information, see set and get variables.

This feature is available in the following product plan(s): Prefect OSS, Prefect Cloud (Free), Prefect Cloud (Pro), Prefect Cloud (Enterprise).

Example Usage

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

const example = new prefect.Variable("example", {value: "variable value goes here"});
Copy
import pulumi
import pulumi_prefect as prefect

example = prefect.Variable("example", value="variable value goes here")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/prefect/v2/prefect"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := prefect.NewVariable(ctx, "example", &prefect.VariableArgs{
			Value: pulumi.Any("variable value goes here"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Prefect = Pulumi.Prefect;

return await Deployment.RunAsync(() => 
{
    var example = new Prefect.Variable("example", new()
    {
        Value = "variable value goes here",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.prefect.Variable;
import com.pulumi.prefect.VariableArgs;
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) {
        var example = new Variable("example", VariableArgs.builder()
            .value("variable value goes here")
            .build());

    }
}
Copy
resources:
  example:
    type: prefect:Variable
    properties:
      value: variable value goes here
Copy

Create Variable Resource

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

Constructor syntax

new Variable(name: string, args: VariableArgs, opts?: CustomResourceOptions);
@overload
def Variable(resource_name: str,
             args: VariableArgs,
             opts: Optional[ResourceOptions] = None)

@overload
def Variable(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             value: Optional[Any] = None,
             account_id: Optional[str] = None,
             name: Optional[str] = None,
             tags: Optional[Sequence[str]] = None,
             workspace_id: Optional[str] = None)
func NewVariable(ctx *Context, name string, args VariableArgs, opts ...ResourceOption) (*Variable, error)
public Variable(string name, VariableArgs args, CustomResourceOptions? opts = null)
public Variable(String name, VariableArgs args)
public Variable(String name, VariableArgs args, CustomResourceOptions options)
type: prefect:Variable
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. VariableArgs
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 variableResource = new Prefect.Variable("variableResource", new()
{
    Value = "any",
    AccountId = "string",
    Name = "string",
    Tags = new[]
    {
        "string",
    },
    WorkspaceId = "string",
});
Copy
example, err := prefect.NewVariable(ctx, "variableResource", &prefect.VariableArgs{
Value: pulumi.Any("any"),
AccountId: pulumi.String("string"),
Name: pulumi.String("string"),
Tags: pulumi.StringArray{
pulumi.String("string"),
},
WorkspaceId: pulumi.String("string"),
})
Copy
var variableResource = new Variable("variableResource", VariableArgs.builder()
    .value("any")
    .accountId("string")
    .name("string")
    .tags("string")
    .workspaceId("string")
    .build());
Copy
variable_resource = prefect.Variable("variableResource",
    value="any",
    account_id="string",
    name="string",
    tags=["string"],
    workspace_id="string")
Copy
const variableResource = new prefect.Variable("variableResource", {
    value: "any",
    accountId: "string",
    name: "string",
    tags: ["string"],
    workspaceId: "string",
});
Copy
type: prefect:Variable
properties:
    accountId: string
    name: string
    tags:
        - string
    value: any
    workspaceId: string
Copy

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

Value This property is required. object
AccountId string
Account ID (UUID), defaults to the account set in the provider
Name string
Name of the variable
Tags List<string>
Tags associated with the variable
WorkspaceId string
Workspace ID (UUID), defaults to the workspace set in the provider
Value This property is required. interface{}
AccountId string
Account ID (UUID), defaults to the account set in the provider
Name string
Name of the variable
Tags []string
Tags associated with the variable
WorkspaceId string
Workspace ID (UUID), defaults to the workspace set in the provider
value This property is required. Object
accountId String
Account ID (UUID), defaults to the account set in the provider
name String
Name of the variable
tags List<String>
Tags associated with the variable
workspaceId String
Workspace ID (UUID), defaults to the workspace set in the provider
value This property is required. any
accountId string
Account ID (UUID), defaults to the account set in the provider
name string
Name of the variable
tags string[]
Tags associated with the variable
workspaceId string
Workspace ID (UUID), defaults to the workspace set in the provider
value This property is required. Any
account_id str
Account ID (UUID), defaults to the account set in the provider
name str
Name of the variable
tags Sequence[str]
Tags associated with the variable
workspace_id str
Workspace ID (UUID), defaults to the workspace set in the provider
value This property is required. Any
accountId String
Account ID (UUID), defaults to the account set in the provider
name String
Name of the variable
tags List<String>
Tags associated with the variable
workspaceId String
Workspace ID (UUID), defaults to the workspace set in the provider

Outputs

All input properties are implicitly available as output properties. Additionally, the Variable resource produces the following output properties:

Created string
Timestamp of when the resource was created (RFC3339)
Id string
The provider-assigned unique ID for this managed resource.
Updated string
Timestamp of when the resource was updated (RFC3339)
Created string
Timestamp of when the resource was created (RFC3339)
Id string
The provider-assigned unique ID for this managed resource.
Updated string
Timestamp of when the resource was updated (RFC3339)
created String
Timestamp of when the resource was created (RFC3339)
id String
The provider-assigned unique ID for this managed resource.
updated String
Timestamp of when the resource was updated (RFC3339)
created string
Timestamp of when the resource was created (RFC3339)
id string
The provider-assigned unique ID for this managed resource.
updated string
Timestamp of when the resource was updated (RFC3339)
created str
Timestamp of when the resource was created (RFC3339)
id str
The provider-assigned unique ID for this managed resource.
updated str
Timestamp of when the resource was updated (RFC3339)
created String
Timestamp of when the resource was created (RFC3339)
id String
The provider-assigned unique ID for this managed resource.
updated String
Timestamp of when the resource was updated (RFC3339)

Look up Existing Variable Resource

Get an existing Variable 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?: VariableState, opts?: CustomResourceOptions): Variable
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        account_id: Optional[str] = None,
        created: Optional[str] = None,
        name: Optional[str] = None,
        tags: Optional[Sequence[str]] = None,
        updated: Optional[str] = None,
        value: Optional[Any] = None,
        workspace_id: Optional[str] = None) -> Variable
func GetVariable(ctx *Context, name string, id IDInput, state *VariableState, opts ...ResourceOption) (*Variable, error)
public static Variable Get(string name, Input<string> id, VariableState? state, CustomResourceOptions? opts = null)
public static Variable get(String name, Output<String> id, VariableState state, CustomResourceOptions options)
resources:  _:    type: prefect:Variable    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
AccountId string
Account ID (UUID), defaults to the account set in the provider
Created string
Timestamp of when the resource was created (RFC3339)
Name string
Name of the variable
Tags List<string>
Tags associated with the variable
Updated string
Timestamp of when the resource was updated (RFC3339)
Value object
WorkspaceId string
Workspace ID (UUID), defaults to the workspace set in the provider
AccountId string
Account ID (UUID), defaults to the account set in the provider
Created string
Timestamp of when the resource was created (RFC3339)
Name string
Name of the variable
Tags []string
Tags associated with the variable
Updated string
Timestamp of when the resource was updated (RFC3339)
Value interface{}
WorkspaceId string
Workspace ID (UUID), defaults to the workspace set in the provider
accountId String
Account ID (UUID), defaults to the account set in the provider
created String
Timestamp of when the resource was created (RFC3339)
name String
Name of the variable
tags List<String>
Tags associated with the variable
updated String
Timestamp of when the resource was updated (RFC3339)
value Object
workspaceId String
Workspace ID (UUID), defaults to the workspace set in the provider
accountId string
Account ID (UUID), defaults to the account set in the provider
created string
Timestamp of when the resource was created (RFC3339)
name string
Name of the variable
tags string[]
Tags associated with the variable
updated string
Timestamp of when the resource was updated (RFC3339)
value any
workspaceId string
Workspace ID (UUID), defaults to the workspace set in the provider
account_id str
Account ID (UUID), defaults to the account set in the provider
created str
Timestamp of when the resource was created (RFC3339)
name str
Name of the variable
tags Sequence[str]
Tags associated with the variable
updated str
Timestamp of when the resource was updated (RFC3339)
value Any
workspace_id str
Workspace ID (UUID), defaults to the workspace set in the provider
accountId String
Account ID (UUID), defaults to the account set in the provider
created String
Timestamp of when the resource was created (RFC3339)
name String
Name of the variable
tags List<String>
Tags associated with the variable
updated String
Timestamp of when the resource was updated (RFC3339)
value Any
workspaceId String
Workspace ID (UUID), defaults to the workspace set in the provider

Import

prefect_variable resources can be imported by the name/name_of_variable identifier

$ pulumi import prefect:index/variable:Variable example name/name_of_variable
Copy

or via variable_id

$ pulumi import prefect:index/variable:Variable example 00000000-0000-0000-0000-000000000000
Copy

or from a different workspace via name/variable_name,workspace_id

$ pulumi import prefect:index/variable:Variable example name/name_of_variable,11111111-1111-1111-1111-111111111111
Copy

or from a different workspace via variable_id,workspace_id

$ pulumi import prefect:index/variable:Variable example 00000000-0000-0000-0000-000000000000,11111111-1111-1111-1111-111111111111
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

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