Workflow

class aws_cdk.aws_glue_alpha.Workflow(scope, id, *, default_run_properties=None, description=None, max_concurrent_runs=None, workflow_name=None)

Bases: WorkflowBase

(experimental) This module defines a construct for creating and managing AWS Glue Workflows and Triggers.

AWS Glue Workflows are orchestration services that allow you to create, manage, and monitor complex extract, transform, and load (ETL) activities involving multiple crawlers, jobs, and triggers. Workflows are designed to allow you to manage interdependent jobs and crawlers as a single unit, making it easier to orchestrate and monitor complex ETL pipelines.

Triggers are used to initiate an AWS Glue Workflow. You can configure different types of triggers, such as on-demand, scheduled, event-based, or conditional triggers, to start your Workflow based on specific conditions or events.

See:

https://docs.aws.amazon.com/glue/latest/dg/about-triggers.html

Usage Example

Example:

const app = new App(); const stack = new Stack(app, ‘TestStack’);

// Create a Glue Job declare const role: iam.IRole; declare const script: glue.Code; const job = new glue.PySparkStreamingJob(stack, ‘ImportedJob’, { role, script });

// Create a Glue Workflow const workflow = new glue.Workflow(stack, ‘TestWorkflow’);

// Add an on-demand trigger to the Workflow workflow.addOnDemandTrigger(‘OnDemandTrigger’, { actions: [{ job: job }], }); :stability: experimental :exampleMetadata: fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_glue_alpha as glue_alpha

workflow = glue_alpha.Workflow(self, "MyWorkflow",
    default_run_properties={
        "default_run_properties_key": "defaultRunProperties"
    },
    description="description",
    max_concurrent_runs=123,
    workflow_name="workflowName"
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • default_run_properties (Optional[Mapping[str, str]]) – (experimental) A map of properties to use when this workflow is executed. Default: - no default run properties

  • description (Optional[str]) – (experimental) A description of the workflow. Default: - no description

  • max_concurrent_runs (Union[int, float, None]) – (experimental) The maximum number of concurrent runs allowed for the workflow. Default: - no limit

  • workflow_name (Optional[str]) – (experimental) Name of the workflow. Default: - a name will be generated

Stability:

experimental

Methods

add_conditional_trigger(id, *, predicate, start_on_creation=None, actions, description=None, name=None)

(experimental) Add a Condition (Predicate) based trigger to the workflow.

Parameters:
  • id (str) – The id of the trigger.

  • predicate (Union[Predicate, Dict[str, Any]]) – (experimental) The predicate for the trigger.

  • start_on_creation (Optional[bool]) – (experimental) Whether to start the trigger on creation or not. Default: - false

  • actions (Sequence[Union[Action, Dict[str, Any]]]) – (experimental) The actions initiated by this trigger.

  • description (Optional[str]) – (experimental) A description for the trigger. Default: - no description

  • name (Optional[str]) – (experimental) A name for the trigger. Default: - no name is provided

Return type:

CfnTrigger

Returns:

The created CfnTrigger resource.

Stability:

experimental

Throws:

If a job is provided without a job state, or if a crawler is provided without a crawler state for any condition.

add_custom_scheduled_trigger(id, *, schedule, start_on_creation=None, actions, description=None, name=None)

(experimental) Add a custom-scheduled trigger to the workflow.

Parameters:
  • id (str) – The id of the trigger.

  • schedule (TriggerSchedule) – (experimental) The custom schedule for the trigger.

  • start_on_creation (Optional[bool]) – (experimental) Whether to start the trigger on creation or not. Default: - false

  • actions (Sequence[Union[Action, Dict[str, Any]]]) – (experimental) The actions initiated by this trigger.

  • description (Optional[str]) – (experimental) A description for the trigger. Default: - no description

  • name (Optional[str]) – (experimental) A name for the trigger. Default: - no name is provided

Return type:

CfnTrigger

Returns:

The created CfnTrigger resource.

Stability:

experimental

Throws:

If both job and crawler are provided, or if neither job nor crawler is provided.

add_daily_scheduled_trigger(id, *, start_on_creation=None, actions, description=None, name=None)

(experimental) Add a daily-scheduled trigger to the workflow.

Parameters:
  • id (str) – The id of the trigger.

  • start_on_creation (Optional[bool]) – (experimental) Whether to start the trigger on creation or not. Default: - false

  • actions (Sequence[Union[Action, Dict[str, Any]]]) – (experimental) The actions initiated by this trigger.

  • description (Optional[str]) – (experimental) A description for the trigger. Default: - no description

  • name (Optional[str]) – (experimental) A name for the trigger. Default: - no name is provided

Return type:

CfnTrigger

Returns:

The created CfnTrigger resource.

Stability:

experimental

Throws:

If both job and crawler are provided, or if neither job nor crawler is provided.

add_notify_event_trigger(id, *, event_batching_condition=None, actions, description=None, name=None)

(experimental) Add an Event Bridge based trigger to the workflow.

Parameters:
  • id (str) – The id of the trigger.

  • event_batching_condition (Union[EventBatchingCondition, Dict[str, Any], None]) – (experimental) Batch condition for the trigger. Default: - no batch condition

  • actions (Sequence[Union[Action, Dict[str, Any]]]) – (experimental) The actions initiated by this trigger.

  • description (Optional[str]) – (experimental) A description for the trigger. Default: - no description

  • name (Optional[str]) – (experimental) A name for the trigger. Default: - no name is provided

Return type:

CfnTrigger

Returns:

The created CfnTrigger resource.

Stability:

experimental

Throws:

If both job and crawler are provided, or if neither job nor crawler is provided.

add_on_demand_trigger(id, *, actions, description=None, name=None)

(experimental) Add an on-demand trigger to the workflow.

Parameters:
  • id (str) – The id of the trigger.

  • actions (Sequence[Union[Action, Dict[str, Any]]]) – (experimental) The actions initiated by this trigger.

  • description (Optional[str]) – (experimental) A description for the trigger. Default: - no description

  • name (Optional[str]) – (experimental) A name for the trigger. Default: - no name is provided

Return type:

CfnTrigger

Returns:

The created CfnTrigger resource.

Stability:

experimental

Throws:

If both job and crawler are provided, or if neither job nor crawler is provided.

add_weekly_scheduled_trigger(id, *, start_on_creation=None, actions, description=None, name=None)

(experimental) Add a weekly-scheduled trigger to the workflow.

Parameters:
  • id (str) – The id of the trigger.

  • start_on_creation (Optional[bool]) – (experimental) Whether to start the trigger on creation or not. Default: - false

  • actions (Sequence[Union[Action, Dict[str, Any]]]) – (experimental) The actions initiated by this trigger.

  • description (Optional[str]) – (experimental) A description for the trigger. Default: - no description

  • name (Optional[str]) – (experimental) A name for the trigger. Default: - no name is provided

Return type:

CfnTrigger

Returns:

The created CfnTrigger resource.

Stability:

experimental

Throws:

If both job and crawler are provided, or if neither job nor crawler is provided.

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

node

The tree node.

stack

The stack in which this resource is defined.

workflow_arn

(experimental) The ARN of the workflow.

Stability:

experimental

workflow_name

(experimental) The name of the workflow.

Stability:

experimental

Static Methods

classmethod extract_name_from_arn(scope, workflow_arn)

(experimental) Extract workflowName from arn.

Parameters:
  • scope (Construct) –

  • workflow_arn (str) –

Stability:

experimental

Return type:

str

classmethod from_workflow_arn(scope, id, workflow_arn)

(experimental) Import an workflow from it’s name.

Parameters:
  • scope (Construct) –

  • id (str) –

  • workflow_arn (str) –

Stability:

experimental

Return type:

IWorkflow

classmethod from_workflow_attributes(scope, id, *, workflow_name, workflow_arn=None)

(experimental) Import an existing workflow.

Parameters:
  • scope (Construct) –

  • id (str) –

  • workflow_name (str) – (experimental) The name of the workflow to import.

  • workflow_arn (Optional[str]) – (experimental) The ARN of the workflow to import. Default: - derived from the workflow name

Stability:

experimental

Return type:

IWorkflow

classmethod from_workflow_name(scope, id, workflow_name)

(experimental) Import a workflow from its name.

Parameters:
  • scope (Construct) –

  • id (str) –

  • workflow_name (str) –

Stability:

experimental

Return type:

IWorkflow

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool