1. Packages
  2. Prefect Provider
  3. API Docs
  4. Flow
prefect 2.25.0 published on Monday, Apr 21, 2025 by prefecthq

prefect.Flow

Explore with Pulumi AI

The resource flow represents a Prefect Flow. Flows are the most central Prefect object. A flow is a container for workflow logic as-code and allows users to configure how their workflows behave. Flows are defined as Python functions, and any Python function is eligible to be a flow. For more information, see write and run flows.

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 workspace = new prefect.Workspace("workspace", {handle: "my-workspace"});
const flow = new prefect.Flow("flow", {
    workspaceId: workspace.id,
    tags: ["tf-test"],
});
Copy
import pulumi
import pulumi_prefect as prefect

workspace = prefect.Workspace("workspace", handle="my-workspace")
flow = prefect.Flow("flow",
    workspace_id=workspace.id,
    tags=["tf-test"])
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 {
		workspace, err := prefect.NewWorkspace(ctx, "workspace", &prefect.WorkspaceArgs{
			Handle: pulumi.String("my-workspace"),
		})
		if err != nil {
			return err
		}
		_, err = prefect.NewFlow(ctx, "flow", &prefect.FlowArgs{
			WorkspaceId: workspace.ID(),
			Tags: pulumi.StringArray{
				pulumi.String("tf-test"),
			},
		})
		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 workspace = new Prefect.Workspace("workspace", new()
    {
        Handle = "my-workspace",
    });

    var flow = new Prefect.Flow("flow", new()
    {
        WorkspaceId = workspace.Id,
        Tags = new[]
        {
            "tf-test",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.prefect.Workspace;
import com.pulumi.prefect.WorkspaceArgs;
import com.pulumi.prefect.Flow;
import com.pulumi.prefect.FlowArgs;
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 workspace = new Workspace("workspace", WorkspaceArgs.builder()
            .handle("my-workspace")
            .build());

        var flow = new Flow("flow", FlowArgs.builder()
            .workspaceId(workspace.id())
            .tags("tf-test")
            .build());

    }
}
Copy
resources:
  workspace:
    type: prefect:Workspace
    properties:
      handle: my-workspace
  flow:
    type: prefect:Flow
    properties:
      workspaceId: ${workspace.id}
      tags:
        - tf-test
Copy

Create Flow Resource

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

Constructor syntax

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

@overload
def Flow(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         account_id: Optional[str] = None,
         name: Optional[str] = None,
         tags: Optional[Sequence[str]] = None,
         workspace_id: Optional[str] = None)
func NewFlow(ctx *Context, name string, args *FlowArgs, opts ...ResourceOption) (*Flow, error)
public Flow(string name, FlowArgs? args = null, CustomResourceOptions? opts = null)
public Flow(String name, FlowArgs args)
public Flow(String name, FlowArgs args, CustomResourceOptions options)
type: prefect:Flow
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 FlowArgs
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 FlowArgs
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 FlowArgs
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 FlowArgs
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. FlowArgs
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 flowResource = new Prefect.Flow("flowResource", new()
{
    AccountId = "string",
    Name = "string",
    Tags = new[]
    {
        "string",
    },
    WorkspaceId = "string",
});
Copy
example, err := prefect.NewFlow(ctx, "flowResource", &prefect.FlowArgs{
	AccountId: pulumi.String("string"),
	Name:      pulumi.String("string"),
	Tags: pulumi.StringArray{
		pulumi.String("string"),
	},
	WorkspaceId: pulumi.String("string"),
})
Copy
var flowResource = new Flow("flowResource", FlowArgs.builder()
    .accountId("string")
    .name("string")
    .tags("string")
    .workspaceId("string")
    .build());
Copy
flow_resource = prefect.Flow("flowResource",
    account_id="string",
    name="string",
    tags=["string"],
    workspace_id="string")
Copy
const flowResource = new prefect.Flow("flowResource", {
    accountId: "string",
    name: "string",
    tags: ["string"],
    workspaceId: "string",
});
Copy
type: prefect:Flow
properties:
    accountId: string
    name: string
    tags:
        - string
    workspaceId: string
Copy

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

AccountId string
Account ID (UUID), defaults to the account set in the provider
Name string
Name of the flow
Tags List<string>
Tags associated with the flow
WorkspaceId string
Workspace ID (UUID)
AccountId string
Account ID (UUID), defaults to the account set in the provider
Name string
Name of the flow
Tags []string
Tags associated with the flow
WorkspaceId string
Workspace ID (UUID)
accountId String
Account ID (UUID), defaults to the account set in the provider
name String
Name of the flow
tags List<String>
Tags associated with the flow
workspaceId String
Workspace ID (UUID)
accountId string
Account ID (UUID), defaults to the account set in the provider
name string
Name of the flow
tags string[]
Tags associated with the flow
workspaceId string
Workspace ID (UUID)
account_id str
Account ID (UUID), defaults to the account set in the provider
name str
Name of the flow
tags Sequence[str]
Tags associated with the flow
workspace_id str
Workspace ID (UUID)
accountId String
Account ID (UUID), defaults to the account set in the provider
name String
Name of the flow
tags List<String>
Tags associated with the flow
workspaceId String
Workspace ID (UUID)

Outputs

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

Get an existing Flow 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?: FlowState, opts?: CustomResourceOptions): Flow
@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,
        workspace_id: Optional[str] = None) -> Flow
func GetFlow(ctx *Context, name string, id IDInput, state *FlowState, opts ...ResourceOption) (*Flow, error)
public static Flow Get(string name, Input<string> id, FlowState? state, CustomResourceOptions? opts = null)
public static Flow get(String name, Output<String> id, FlowState state, CustomResourceOptions options)
resources:  _:    type: prefect:Flow    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 flow
Tags List<string>
Tags associated with the flow
Updated string
Timestamp of when the resource was updated (RFC3339)
WorkspaceId string
Workspace ID (UUID)
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 flow
Tags []string
Tags associated with the flow
Updated string
Timestamp of when the resource was updated (RFC3339)
WorkspaceId string
Workspace ID (UUID)
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 flow
tags List<String>
Tags associated with the flow
updated String
Timestamp of when the resource was updated (RFC3339)
workspaceId String
Workspace ID (UUID)
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 flow
tags string[]
Tags associated with the flow
updated string
Timestamp of when the resource was updated (RFC3339)
workspaceId string
Workspace ID (UUID)
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 flow
tags Sequence[str]
Tags associated with the flow
updated str
Timestamp of when the resource was updated (RFC3339)
workspace_id str
Workspace ID (UUID)
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 flow
tags List<String>
Tags associated with the flow
updated String
Timestamp of when the resource was updated (RFC3339)
workspaceId String
Workspace ID (UUID)

Import

Prefect Flows can be imported via flow_id

$ pulumi import prefect:index/flow:Flow example 00000000-0000-0000-0000-000000000000
Copy

or from a different workspace via flow_id,workspace_id

$ pulumi import prefect:index/flow:Flow example 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000
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.