AWS CloudFormation
User Guide (Version )

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

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, "Name" : String, "Predicate" : Predicate, "Schedule" : String, "Tags" : Json, "Type" : String } }

YAML

Type: AWS::Glue::Trigger Properties: Actions: - Action Description: String Name: String Predicate: Predicate Schedule: String Tags: Json Type: String

Properties

Actions

The actions initiated by this trigger.

Required: Yes

Type: List of Action

Update requires: No interruption

Description

A description of this trigger.

Required: No

Type: String

Update requires: No interruption

Name

The name of the trigger.

Required: No

Type: String

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

Tags

The tags to use with this trigger.

Required: No

Type: Json

Update requires: No interruption

Type

The type of trigger that this is.

Required: Yes

Type: String

Update requires: No interruption

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.

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