AWS::Glue::Trigger - AWS CloudFormation

AWS::Glue::Trigger

The AWS::Glue::Trigger resource specifies triggers that run AWS Glue jobs. For more information, see Triggering Jobs in AWS Glue and Trigger Structure in the AWS Glue Developer Guide.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::Glue::Trigger", "Properties" : { "Actions" : [ Action, ... ], "Description" : String, "EventBatchingCondition" : EventBatchingCondition, "Name" : String, "Predicate" : Predicate, "Schedule" : String, "StartOnCreation" : Boolean, "Tags" : [ Tag, ... ], "Type" : String, "WorkflowName" : String } }

YAML

Type: AWS::Glue::Trigger Properties: Actions: - Action Description: String EventBatchingCondition: EventBatchingCondition Name: String Predicate: Predicate Schedule: String StartOnCreation: Boolean Tags: - Tag Type: String WorkflowName: String

Properties

Actions

The actions initiated by this trigger.

Required: Yes

Type: Array of Action

Update requires: No interruption

Description

A description of this trigger.

Required: No

Type: String

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Minimum: 0

Maximum: 2048

Update requires: No interruption

EventBatchingCondition

Batch condition that must be met (specified number of events received or batch time window expired) before EventBridge event trigger fires.

Required: No

Type: EventBatchingCondition

Update requires: No interruption

Name

The name of the trigger.

Required: No

Type: String

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\t]*

Minimum: 1

Maximum: 255

Update requires: Replacement

Predicate

The predicate of this trigger, which defines when it will fire.

Required: No

Type: Predicate

Update requires: No interruption

Schedule

A cron expression used to specify the schedule. For more information, see Time-Based Schedules for Jobs and Crawlers in the AWS Glue Developer Guide. For example, to run something every day at 12:15 UTC, specify cron(15 12 * * ? *).

Required: No

Type: String

Update requires: No interruption

StartOnCreation

Set to true to start SCHEDULED and CONDITIONAL triggers when created. True is not supported for ON_DEMAND triggers.

Required: No

Type: Boolean

Update requires: No interruption

Tags

The tags to use with this trigger.

Required: No

Type: Array of Tag

Update requires: No interruption

Type

The type of trigger that this is.

Required: Yes

Type: String

Allowed values: SCHEDULED | CONDITIONAL | ON_DEMAND | EVENT

Update requires: Replacement

WorkflowName

The name of the workflow associated with the trigger.

Required: No

Type: String

Update requires: Replacement

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the trigger name.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Id

Reserved for future use.

Examples

On-Demand Trigger

The following example creates an on-demand trigger that triggers one job.

JSON

{ "Resources": { "OnDemandJobTrigger": { "Type": "AWS::Glue::Trigger", "Properties": { "Type": "ON_DEMAND", "Description": "DESCRIPTION_ON_DEMAND", "Actions": [ { "JobName": "prod-job2" } ], "Name": "prod-trigger1-ondemand" } } } }

YAML

Resources: OnDemandJobTrigger: Type: AWS::Glue::Trigger Properties: Type: ON_DEMAND Description: DESCRIPTION_ON_DEMAND Actions: - JobName: prod-job2 Name: prod-trigger1-ondemand

Scheduled Trigger

The following example creates a scheduled trigger that runs every two hours and triggers two jobs. Note that it declares an argument for prod-job3.

JSON

{ "Resources": { "ScheduledJobTrigger": { "Type": "AWS::Glue::Trigger", "Properties": { "Type": "SCHEDULED", "Description": "DESCRIPTION_SCHEDULED", "Schedule": "cron(0 */2 * * ? *)", "Actions": [ { "JobName": "prod-job2" }, { "JobName": "prod-job3", "Arguments": { "--job-bookmark-option": "job-bookmark-enable" } } ], "Name": "prod-trigger1-scheduled" } } } }

YAML

Resources: ScheduledJobTrigger: Type: AWS::Glue::Trigger Properties: Type: SCHEDULED Description: DESCRIPTION_SCHEDULED Schedule: cron(0 */2 * * ? *) Actions: - JobName: prod-job2 - JobName: prod-job3 Arguments: '--job-bookmark-option': job-bookmark-enable Name: prod-trigger1-scheduled

Conditional Trigger

The following example creates a conditional trigger that starts a job based on the successful completion of the job run.

JSON

{ "Description": "AWS Glue trigger test", "Resources": { "MyJobTriggerRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "glue.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] }, "Path": "/", "Policies": [ { "PolicyName": "root", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "*", "Resource": "*" } ] } } ] } }, "MyJob": { "Type": "AWS::Glue::Job", "Properties": { "Name": "MyJobTriggerJob", "LogUri": "wikiData", "Role": { "Ref": "MyJobTriggerRole" }, "Command": { "Name": "glueetl", "ScriptLocation": "s3://testdata-bucket/s3-target/create-delete-job-xtf-ETL-s3-json-to-csv.py" }, "DefaultArguments": { "--job-bookmark-option": "job-bookmark-enable" }, "MaxRetries": 0 } }, "MyJobTrigger": { "Type": "AWS::Glue::Trigger", "Properties": { "Name": "MyJobTrigger", "Type": "CONDITIONAL", "Description": "Description for a conditional job trigger", "Actions": [ { "JobName": { "Ref": "MyJob" }, "Arguments": { "--job-bookmark-option": "job-bookmark-enable" } } ], "Predicate": { "Conditions": [ { "LogicalOperator": "EQUALS", "JobName": { "Ref": "MyJob" }, "State": "SUCCEEDED" } ] } } } } }

YAML

--- Description: "AWS Glue trigger test" Resources: MyJobTriggerRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: - "glue.amazonaws.com" Action: - "sts:AssumeRole" Path: "/" Policies: - PolicyName: "root" PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: "*" Resource: "*" MyJob: Type: AWS::Glue::Job Properties: Name: "MyJobTriggerJob" LogUri: "wikiData" Role: !Ref MyJobTriggerRole Command: Name: "glueetl" ScriptLocation: "s3://testdata-bucket/s3-target/create-delete-job-xtf-ETL-s3-json-to-csv.py" DefaultArguments: "--job-bookmark-option": "job-bookmark-enable" MaxRetries: 0 MyJobTrigger: Type: AWS::Glue::Trigger Properties: Name: "MyJobTrigger" Type: "CONDITIONAL" Description: "Description for a conditional job trigger" Actions: - JobName: !Ref MyJob Arguments: "--job-bookmark-option": "job-bookmark-enable" Predicate: Conditions: - LogicalOperator: EQUALS JobName: !Ref MyJob State: SUCCEEDED