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

prefect.TaskRunConcurrencyLimit

Explore with Pulumi AI

The resource task_run_concurrency_limit represents a task run concurrency limit. Task run concurrency limits allow you to control how many tasks with specific tags can run simultaneously. For more information, see limit concurrent task runs with tags.

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 testWorkspace = prefect.getWorkspace({
    handle: "my-workspace",
});
const testTaskRunConcurrencyLimit = new prefect.TaskRunConcurrencyLimit("testTaskRunConcurrencyLimit", {
    workspaceId: testWorkspace.then(testWorkspace => testWorkspace.id),
    concurrencyLimit: 1,
    tag: "test-tag",
});
// Example of a task that will be limited to 1 concurrent run:
//from prefect import flow, task
//
//# This task will be limited to 1 concurrent run
//@task(tags=["test-tag"])
//def my_task():
//    print("Hello, I'm a task")
//
//
//@flow
//def my_flow():
//    my_task()
//
//
//if __name__ == "__main__":
//    my_flow()
Copy
import pulumi
import pulumi_prefect as prefect

test_workspace = prefect.get_workspace(handle="my-workspace")
test_task_run_concurrency_limit = prefect.TaskRunConcurrencyLimit("testTaskRunConcurrencyLimit",
    workspace_id=test_workspace.id,
    concurrency_limit=1,
    tag="test-tag")
# Example of a task that will be limited to 1 concurrent run:
#from prefect import flow, task
#
## This task will be limited to 1 concurrent run
#@task(tags=["test-tag"])
#def my_task():
#    print("Hello, I'm a task")
#
#
#@flow
#def my_flow():
#    my_task()
#
#
#if __name__ == "__main__":
#    my_flow()
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 {
		testWorkspace, err := prefect.LookupWorkspace(ctx, &prefect.LookupWorkspaceArgs{
			Handle: pulumi.StringRef("my-workspace"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = prefect.NewTaskRunConcurrencyLimit(ctx, "testTaskRunConcurrencyLimit", &prefect.TaskRunConcurrencyLimitArgs{
			WorkspaceId:      pulumi.String(testWorkspace.Id),
			ConcurrencyLimit: pulumi.Float64(1),
			Tag:              pulumi.String("test-tag"),
		})
		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 testWorkspace = Prefect.GetWorkspace.Invoke(new()
    {
        Handle = "my-workspace",
    });

    var testTaskRunConcurrencyLimit = new Prefect.TaskRunConcurrencyLimit("testTaskRunConcurrencyLimit", new()
    {
        WorkspaceId = testWorkspace.Apply(getWorkspaceResult => getWorkspaceResult.Id),
        ConcurrencyLimit = 1,
        Tag = "test-tag",
    });

    // Example of a task that will be limited to 1 concurrent run:
    //from prefect import flow, task
    //
    //# This task will be limited to 1 concurrent run
    //@task(tags=["test-tag"])
    //def my_task():
    //    print("Hello, I'm a task")
    //
    //
    //@flow
    //def my_flow():
    //    my_task()
    //
    //
    //if __name__ == "__main__":
    //    my_flow()
});
Copy
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.GetWorkspaceArgs;
import com.pulumi.prefect.TaskRunConcurrencyLimit;
import com.pulumi.prefect.TaskRunConcurrencyLimitArgs;
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 testWorkspace = PrefectFunctions.getWorkspace(GetWorkspaceArgs.builder()
            .handle("my-workspace")
            .build());

        var testTaskRunConcurrencyLimit = new TaskRunConcurrencyLimit("testTaskRunConcurrencyLimit", TaskRunConcurrencyLimitArgs.builder()
            .workspaceId(testWorkspace.applyValue(getWorkspaceResult -> getWorkspaceResult.id()))
            .concurrencyLimit(1)
            .tag("test-tag")
            .build());

        // Example of a task that will be limited to 1 concurrent run:
        //from prefect import flow, task
        //
        //# This task will be limited to 1 concurrent run
        //@task(tags=["test-tag"])
        //def my_task():
        //    print("Hello, I'm a task")
        //
        //
        //@flow
        //def my_flow():
        //    my_task()
        //
        //
        //if __name__ == "__main__":
        //    my_flow()
    }
}
Copy
resources:
  testTaskRunConcurrencyLimit: # Example of a task that will be limited to 1 concurrent run:
  # /*
  # from prefect import flow, task

  # This task will be limited to 1 concurrent run
  # @task(tags=["test-tag"])
  # def my_task():
  #     print("Hello, I'm a task")


  # @flow
  # def my_flow():
  #     my_task()


  # if __name__ == "__main__":
  #     my_flow()
  # */
    type: prefect:TaskRunConcurrencyLimit
    properties:
      workspaceId: ${testWorkspace.id}
      concurrencyLimit: 1
      tag: test-tag
variables:
  testWorkspace:
    fn::invoke:
      function: prefect:getWorkspace
      arguments:
        handle: my-workspace
Copy

Create TaskRunConcurrencyLimit Resource

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

Constructor syntax

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

@overload
def TaskRunConcurrencyLimit(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            concurrency_limit: Optional[float] = None,
                            tag: Optional[str] = None,
                            account_id: Optional[str] = None,
                            workspace_id: Optional[str] = None)
func NewTaskRunConcurrencyLimit(ctx *Context, name string, args TaskRunConcurrencyLimitArgs, opts ...ResourceOption) (*TaskRunConcurrencyLimit, error)
public TaskRunConcurrencyLimit(string name, TaskRunConcurrencyLimitArgs args, CustomResourceOptions? opts = null)
public TaskRunConcurrencyLimit(String name, TaskRunConcurrencyLimitArgs args)
public TaskRunConcurrencyLimit(String name, TaskRunConcurrencyLimitArgs args, CustomResourceOptions options)
type: prefect:TaskRunConcurrencyLimit
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. TaskRunConcurrencyLimitArgs
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. TaskRunConcurrencyLimitArgs
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. TaskRunConcurrencyLimitArgs
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. TaskRunConcurrencyLimitArgs
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. TaskRunConcurrencyLimitArgs
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 taskRunConcurrencyLimitResource = new Prefect.TaskRunConcurrencyLimit("taskRunConcurrencyLimitResource", new()
{
    ConcurrencyLimit = 0,
    Tag = "string",
    AccountId = "string",
    WorkspaceId = "string",
});
Copy
example, err := prefect.NewTaskRunConcurrencyLimit(ctx, "taskRunConcurrencyLimitResource", &prefect.TaskRunConcurrencyLimitArgs{
ConcurrencyLimit: pulumi.Float64(0),
Tag: pulumi.String("string"),
AccountId: pulumi.String("string"),
WorkspaceId: pulumi.String("string"),
})
Copy
var taskRunConcurrencyLimitResource = new TaskRunConcurrencyLimit("taskRunConcurrencyLimitResource", TaskRunConcurrencyLimitArgs.builder()
    .concurrencyLimit(0)
    .tag("string")
    .accountId("string")
    .workspaceId("string")
    .build());
Copy
task_run_concurrency_limit_resource = prefect.TaskRunConcurrencyLimit("taskRunConcurrencyLimitResource",
    concurrency_limit=0,
    tag="string",
    account_id="string",
    workspace_id="string")
Copy
const taskRunConcurrencyLimitResource = new prefect.TaskRunConcurrencyLimit("taskRunConcurrencyLimitResource", {
    concurrencyLimit: 0,
    tag: "string",
    accountId: "string",
    workspaceId: "string",
});
Copy
type: prefect:TaskRunConcurrencyLimit
properties:
    accountId: string
    concurrencyLimit: 0
    tag: string
    workspaceId: string
Copy

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

ConcurrencyLimit This property is required. double
The task run concurrency limit.
Tag This property is required. string
A tag the task run concurrency limit is applied to.
AccountId string
Account ID (UUID)
WorkspaceId string
Workspace ID (UUID)
ConcurrencyLimit This property is required. float64
The task run concurrency limit.
Tag This property is required. string
A tag the task run concurrency limit is applied to.
AccountId string
Account ID (UUID)
WorkspaceId string
Workspace ID (UUID)
concurrencyLimit This property is required. Double
The task run concurrency limit.
tag This property is required. String
A tag the task run concurrency limit is applied to.
accountId String
Account ID (UUID)
workspaceId String
Workspace ID (UUID)
concurrencyLimit This property is required. number
The task run concurrency limit.
tag This property is required. string
A tag the task run concurrency limit is applied to.
accountId string
Account ID (UUID)
workspaceId string
Workspace ID (UUID)
concurrency_limit This property is required. float
The task run concurrency limit.
tag This property is required. str
A tag the task run concurrency limit is applied to.
account_id str
Account ID (UUID)
workspace_id str
Workspace ID (UUID)
concurrencyLimit This property is required. Number
The task run concurrency limit.
tag This property is required. String
A tag the task run concurrency limit is applied to.
accountId String
Account ID (UUID)
workspaceId String
Workspace ID (UUID)

Outputs

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

Get an existing TaskRunConcurrencyLimit 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?: TaskRunConcurrencyLimitState, opts?: CustomResourceOptions): TaskRunConcurrencyLimit
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        account_id: Optional[str] = None,
        concurrency_limit: Optional[float] = None,
        created: Optional[str] = None,
        tag: Optional[str] = None,
        updated: Optional[str] = None,
        workspace_id: Optional[str] = None) -> TaskRunConcurrencyLimit
func GetTaskRunConcurrencyLimit(ctx *Context, name string, id IDInput, state *TaskRunConcurrencyLimitState, opts ...ResourceOption) (*TaskRunConcurrencyLimit, error)
public static TaskRunConcurrencyLimit Get(string name, Input<string> id, TaskRunConcurrencyLimitState? state, CustomResourceOptions? opts = null)
public static TaskRunConcurrencyLimit get(String name, Output<String> id, TaskRunConcurrencyLimitState state, CustomResourceOptions options)
resources:  _:    type: prefect:TaskRunConcurrencyLimit    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)
ConcurrencyLimit double
The task run concurrency limit.
Created string
Timestamp of when the resource was created (RFC3339)
Tag string
A tag the task run concurrency limit is applied to.
Updated string
Timestamp of when the resource was updated (RFC3339)
WorkspaceId string
Workspace ID (UUID)
AccountId string
Account ID (UUID)
ConcurrencyLimit float64
The task run concurrency limit.
Created string
Timestamp of when the resource was created (RFC3339)
Tag string
A tag the task run concurrency limit is applied to.
Updated string
Timestamp of when the resource was updated (RFC3339)
WorkspaceId string
Workspace ID (UUID)
accountId String
Account ID (UUID)
concurrencyLimit Double
The task run concurrency limit.
created String
Timestamp of when the resource was created (RFC3339)
tag String
A tag the task run concurrency limit is applied to.
updated String
Timestamp of when the resource was updated (RFC3339)
workspaceId String
Workspace ID (UUID)
accountId string
Account ID (UUID)
concurrencyLimit number
The task run concurrency limit.
created string
Timestamp of when the resource was created (RFC3339)
tag string
A tag the task run concurrency limit is applied to.
updated string
Timestamp of when the resource was updated (RFC3339)
workspaceId string
Workspace ID (UUID)
account_id str
Account ID (UUID)
concurrency_limit float
The task run concurrency limit.
created str
Timestamp of when the resource was created (RFC3339)
tag str
A tag the task run concurrency limit is applied to.
updated str
Timestamp of when the resource was updated (RFC3339)
workspace_id str
Workspace ID (UUID)
accountId String
Account ID (UUID)
concurrencyLimit Number
The task run concurrency limit.
created String
Timestamp of when the resource was created (RFC3339)
tag String
A tag the task run concurrency limit is applied to.
updated String
Timestamp of when the resource was updated (RFC3339)
workspaceId String
Workspace ID (UUID)

Import

Prefect task run concurrency limits can be imported via task_run_concurrency_limit_id

$ pulumi import prefect:index/taskRunConcurrencyLimit:TaskRunConcurrencyLimit example 00000000-0000-0000-0000-000000000000
Copy

or from a different workspace via task_run_concurrency_limit_id,workspace_id

$ pulumi import prefect:index/taskRunConcurrencyLimit:TaskRunConcurrencyLimit 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.