@aws-cdk/aws-glue-alpha
Version:
The CDK Construct Library for AWS::Glue
206 lines (205 loc) • 7.85 kB
TypeScript
import * as cdk from 'aws-cdk-lib/core';
import * as constructs from 'constructs';
import { CfnTrigger } from 'aws-cdk-lib/aws-glue';
import { OnDemandTriggerOptions, WeeklyScheduleTriggerOptions, DailyScheduleTriggerOptions, CustomScheduledTriggerOptions, NotifyEventTriggerOptions, ConditionalTriggerOptions } from './trigger-options';
/**
* The base interface for Glue Workflow
*
* @see {@link Workflow}
* @see https://docs.aws.amazon.com/glue/latest/dg/workflows_overview.html
*/
export interface IWorkflow extends cdk.IResource {
/**
* The name of the workflow
* @attribute
*/
readonly workflowName: string;
/**
* The ARN of the workflow
* @attribute
*/
readonly workflowArn: string;
/**
* Add an on-demand trigger to the workflow
*/
addOnDemandTrigger(id: string, options: OnDemandTriggerOptions): CfnTrigger;
/**
* Add an daily-scheduled trigger to the workflow
*/
addDailyScheduledTrigger(id: string, options: DailyScheduleTriggerOptions): CfnTrigger;
/**
* Add an weekly-scheduled trigger to the workflow
*/
addWeeklyScheduledTrigger(id: string, options: WeeklyScheduleTriggerOptions): CfnTrigger;
/**
* Add an custom-scheduled trigger to the workflow
*/
addCustomScheduledTrigger(id: string, options: CustomScheduledTriggerOptions): CfnTrigger;
}
/**
* Properties for importing a Workflow using its attributes
*/
export interface WorkflowAttributes {
/**
* The name of the workflow to import
*/
readonly workflowName: string;
/**
* The ARN of the workflow to import
*
* @default - derived from the workflow name
*/
readonly workflowArn?: string;
}
/**
* Properties for defining a Workflow
*/
export interface WorkflowProps {
/**
* Name of the workflow
*
* @default - a name will be generated
*/
readonly workflowName?: string;
/**
* A description of the workflow
*
* @default - no description
*/
readonly description?: string;
/**
* A map of properties to use when this workflow is executed
*
* @default - no default run properties
*/
readonly defaultRunProperties?: {
[key: string]: string;
};
/**
* The maximum number of concurrent runs allowed for the workflow
*
* @default - no limit
*/
readonly maxConcurrentRuns?: number;
}
/**
* Base abstract class for Workflow
*
* @see https://docs.aws.amazon.com/glue/latest/dg/about-triggers.html
*/
export declare abstract class WorkflowBase extends cdk.Resource implements IWorkflow {
/**
* Extract workflowName from arn
*/
protected static extractNameFromArn(scope: constructs.Construct, workflowArn: string): string;
abstract readonly workflowName: string;
abstract readonly workflowArn: string;
/**
* Add an on-demand trigger to the workflow.
*
* @param id The id of the trigger.
* @param options Additional options for the trigger.
* @throws If both job and crawler are provided, or if neither job nor crawler is provided.
* @returns The created CfnTrigger resource.
*/
addOnDemandTrigger(id: string, options: OnDemandTriggerOptions): CfnTrigger;
/**
* Add a daily-scheduled trigger to the workflow.
*
* @param id The id of the trigger.
* @param options Additional options for the trigger.
* @throws If both job and crawler are provided, or if neither job nor crawler is provided.
* @returns The created CfnTrigger resource.
*/
addDailyScheduledTrigger(id: string, options: DailyScheduleTriggerOptions): CfnTrigger;
/**
* Add a weekly-scheduled trigger to the workflow.
*
* @param id The id of the trigger.
* @param options Additional options for the trigger.
* @throws If both job and crawler are provided, or if neither job nor crawler is provided.
* @returns The created CfnTrigger resource.
*/
addWeeklyScheduledTrigger(id: string, options: WeeklyScheduleTriggerOptions): CfnTrigger;
/**
* Add a custom-scheduled trigger to the workflow.
*
* @param id The id of the trigger.
* @param options Additional options for the trigger.
* @throws If both job and crawler are provided, or if neither job nor crawler is provided.
* @returns The created CfnTrigger resource.
*/
addCustomScheduledTrigger(id: string, options: CustomScheduledTriggerOptions): CfnTrigger;
/**
* Add an Event Bridge based trigger to the workflow.
*
* @param id The id of the trigger.
* @param options Additional options for the trigger.
* @throws If both job and crawler are provided, or if neither job nor crawler is provided.
* @returns The created CfnTrigger resource.
*/
addNotifyEventTrigger(id: string, options: NotifyEventTriggerOptions): CfnTrigger;
/**
* Add a Condition (Predicate) based trigger to the workflow.
*
* @param id The id of the trigger.
* @param options Additional options for the trigger.
* @throws If both job and crawler are provided, or if neither job nor crawler is provided for any condition.
* @throws If a job is provided without a job state, or if a crawler is provided without a crawler state for any condition.
* @returns The created CfnTrigger resource.
*/
addConditionalTrigger(id: string, options: ConditionalTriggerOptions): CfnTrigger;
private renderAction;
private renderPredicate;
private renderEventBatchingCondition;
protected buildWorkflowArn(scope: constructs.Construct, workflowName: string): string;
}
/**
* 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/workflows_overview.html
* @see https://docs.aws.amazon.com/glue/latest/dg/about-triggers.html
*
* ## Usage Example
*
* ```ts
* 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 }],
* });
* ```
*/
export declare class Workflow extends WorkflowBase {
/** Uniquely identifies this class. */
static readonly PROPERTY_INJECTION_ID: string;
/**
* Import a workflow from its name
*/
static fromWorkflowName(scope: constructs.Construct, id: string, workflowName: string): IWorkflow;
/**
* Import an workflow from it's name
*/
static fromWorkflowArn(scope: constructs.Construct, id: string, workflowArn: string): IWorkflow;
/**
* Import an existing workflow
*/
static fromWorkflowAttributes(scope: constructs.Construct, id: string, attrs: WorkflowAttributes): IWorkflow;
readonly workflowName: string;
readonly workflowArn: string;
constructor(scope: constructs.Construct, id: string, props?: WorkflowProps);
}