Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

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

Copy
{ "Type" : "AWS::Glue::Trigger", "Properties" : { "Type" : String, "Description" : String, "Actions" : [ Action, ... ], "Schedule" : String, "Name" : String, "Predicate" : Predicate } }

YAML

Copy
Type: "AWS::Glue::Trigger" Properties: Type: String Description: String Actions: - Action Schedule: String Name: String Predicate: Predicate

Properties

Type

The type of job trigger. Valid values are SCHEDULED, CONDITIONAL, or ON_DEMAND.

Required: Yes

Type: String

Update requires: No interruption

Description

The description of the job trigger.

Required: No

Type: String

Update requires: No interruption

Actions

The actions that the job trigger initiates when it fires.

Required: Yes

Type: List of AWS Glue Trigger Action

Update requires: No interruption

Schedule

The cron schedule expression for the job trigger.

Required: No

Type: String

Update requires: No interruption

Name

The name of the job trigger.

Required: No

Type: String

Update requires: Replacement

Predicate

The predicate of the job trigger, which determines when the trigger fires.

Required: No

Type: AWS Glue Trigger Predicate

Update requires: No interruption

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the resource name.

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

Examples

On-Demand Trigger

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

JSON

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

YAML

Copy
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

Copy
{ "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

Copy
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

Copy
{ "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": { "--continuation-option": "continuation-enabled" }, "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

Copy
--- 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: "--continuation-option": "continuation-enabled" 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