prefect 2.90.0 published on Friday, Oct 31, 2025 by prefecthq
prefect.getVariable
Start a Neo task
Explain and create a prefect.getVariable resource
Get information about an existing Variable by name or ID.
Use this data source to obtain Variable-specific attributes, such as the value.
For more information, see get and set variables.
This feature is available in the following product plan(s): Prefect OSS, Hobby, Starter, Team, Pro, Enterprise.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as prefect from "@pulumi/prefect";
const existingById = prefect.getVariable({
id: "00000000-0000-0000-0000-000000000000",
});
const existingByName = prefect.getVariable({
name: "my_variable_name",
});
import pulumi
import pulumi_prefect as prefect
existing_by_id = prefect.get_variable(id="00000000-0000-0000-0000-000000000000")
existing_by_name = prefect.get_variable(name="my_variable_name")
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.LookupVariable(ctx, &prefect.LookupVariableArgs{
Id: pulumi.StringRef("00000000-0000-0000-0000-000000000000"),
}, nil)
if err != nil {
return err
}
_, err = prefect.LookupVariable(ctx, &prefect.LookupVariableArgs{
Name: pulumi.StringRef("my_variable_name"),
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Prefect = Pulumi.Prefect;
return await Deployment.RunAsync(() =>
{
var existingById = Prefect.GetVariable.Invoke(new()
{
Id = "00000000-0000-0000-0000-000000000000",
});
var existingByName = Prefect.GetVariable.Invoke(new()
{
Name = "my_variable_name",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.prefect.PrefectFunctions;
import com.pulumi.prefect.inputs.GetVariableArgs;
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 existingById = PrefectFunctions.getVariable(GetVariableArgs.builder()
.id("00000000-0000-0000-0000-000000000000")
.build());
final var existingByName = PrefectFunctions.getVariable(GetVariableArgs.builder()
.name("my_variable_name")
.build());
}
}
variables:
existingById:
fn::invoke:
function: prefect:getVariable
arguments:
id: 00000000-0000-0000-0000-000000000000
existingByName:
fn::invoke:
function: prefect:getVariable
arguments:
name: my_variable_name
Using getVariable
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 getVariable(args: GetVariableArgs, opts?: InvokeOptions): Promise<GetVariableResult>
function getVariableOutput(args: GetVariableOutputArgs, opts?: InvokeOptions): Output<GetVariableResult>def get_variable(account_id: Optional[str] = None,
id: Optional[str] = None,
name: Optional[str] = None,
workspace_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetVariableResult
def get_variable_output(account_id: Optional[pulumi.Input[str]] = None,
id: Optional[pulumi.Input[str]] = None,
name: Optional[pulumi.Input[str]] = None,
workspace_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetVariableResult]func LookupVariable(ctx *Context, args *LookupVariableArgs, opts ...InvokeOption) (*LookupVariableResult, error)
func LookupVariableOutput(ctx *Context, args *LookupVariableOutputArgs, opts ...InvokeOption) LookupVariableResultOutput> Note: This function is named LookupVariable in the Go SDK.
public static class GetVariable
{
public static Task<GetVariableResult> InvokeAsync(GetVariableArgs args, InvokeOptions? opts = null)
public static Output<GetVariableResult> Invoke(GetVariableInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetVariableResult> getVariable(GetVariableArgs args, InvokeOptions options)
public static Output<GetVariableResult> getVariable(GetVariableArgs args, InvokeOptions options)
fn::invoke:
function: prefect:index/getVariable:getVariable
arguments:
# arguments dictionaryThe following arguments are supported:
- Account
Id string - Account ID (UUID), defaults to the account set in the provider
- Id string
- Variable ID (UUID)
- Name string
- Name of the variable
- Workspace
Id string - Workspace ID (UUID), defaults to the workspace set in the provider
- Account
Id string - Account ID (UUID), defaults to the account set in the provider
- Id string
- Variable ID (UUID)
- Name string
- Name of the variable
- Workspace
Id string - Workspace ID (UUID), defaults to the workspace set in the provider
- account
Id String - Account ID (UUID), defaults to the account set in the provider
- id String
- Variable ID (UUID)
- name String
- Name of the variable
- workspace
Id String - Workspace ID (UUID), defaults to the workspace set in the provider
- account
Id string - Account ID (UUID), defaults to the account set in the provider
- id string
- Variable ID (UUID)
- name string
- Name of the variable
- workspace
Id 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
- id str
- Variable ID (UUID)
- name str
- Name of the variable
- workspace_
id str - Workspace ID (UUID), defaults to the workspace set in the provider
- account
Id String - Account ID (UUID), defaults to the account set in the provider
- id String
- Variable ID (UUID)
- name String
- Name of the variable
- workspace
Id String - Workspace ID (UUID), defaults to the workspace set in the provider
getVariable Result
The following output properties are available:
- Created string
- Timestamp of when the resource was created (RFC3339)
- Id string
- Variable ID (UUID)
- Name string
- Name of the variable
- List<string>
- Tags associated with the variable
- Updated string
- Timestamp of when the resource was updated (RFC3339)
- Value object
- Account
Id string - Account ID (UUID), defaults to the account set in the provider
- Workspace
Id string - Workspace ID (UUID), defaults to the workspace set in the provider
- Created string
- Timestamp of when the resource was created (RFC3339)
- Id string
- Variable ID (UUID)
- Name string
- Name of the variable
- []string
- Tags associated with the variable
- Updated string
- Timestamp of when the resource was updated (RFC3339)
- Value interface{}
- Account
Id string - Account ID (UUID), defaults to the account set in the provider
- Workspace
Id string - Workspace ID (UUID), defaults to the workspace set in the provider
- created String
- Timestamp of when the resource was created (RFC3339)
- id String
- Variable ID (UUID)
- name String
- Name of the variable
- List<String>
- Tags associated with the variable
- updated String
- Timestamp of when the resource was updated (RFC3339)
- value Object
- account
Id String - Account ID (UUID), defaults to the account set in the provider
- workspace
Id String - Workspace ID (UUID), defaults to the workspace set in the provider
- created string
- Timestamp of when the resource was created (RFC3339)
- id string
- Variable ID (UUID)
- name string
- Name of the variable
- string[]
- Tags associated with the variable
- updated string
- Timestamp of when the resource was updated (RFC3339)
- value any
- account
Id string - Account ID (UUID), defaults to the account set in the provider
- workspace
Id string - Workspace ID (UUID), defaults to the workspace set in the provider
- created str
- Timestamp of when the resource was created (RFC3339)
- id str
- Variable ID (UUID)
- name str
- Name of the variable
- Sequence[str]
- Tags associated with the variable
- updated str
- Timestamp of when the resource was updated (RFC3339)
- value Any
- account_
id str - Account ID (UUID), defaults to the account set in the provider
- workspace_
id str - Workspace ID (UUID), defaults to the workspace set in the provider
- created String
- Timestamp of when the resource was created (RFC3339)
- id String
- Variable ID (UUID)
- name String
- Name of the variable
- List<String>
- Tags associated with the variable
- updated String
- Timestamp of when the resource was updated (RFC3339)
- value Any
- account
Id String - Account ID (UUID), defaults to the account set in the provider
- workspace
Id String - Workspace ID (UUID), defaults to the workspace set in the provider
Package Details
- Repository
- prefect prefecthq/terraform-provider-prefect
- License
- Notes
- This Pulumi package is based on the
prefectTerraform Provider.
