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.
To declare this entity in your AWS CloudFormation template, use the following syntax:
{
"Type" : "AWS::Glue::Trigger",
"Properties" : {
"[Actions](#cfn-glue-trigger-actions)" : [ [Action](aws-properties-glue-trigger-action.md), ... ],
"[Description](#cfn-glue-trigger-description)" : String,
"[Name](#cfn-glue-trigger-name)" : String,
"[Predicate](#cfn-glue-trigger-predicate)" : [Predicate](aws-properties-glue-trigger-predicate.md),
"[Schedule](#cfn-glue-trigger-schedule)" : String,
"[StartOnCreation](#cfn-glue-trigger-startoncreation)" : Boolean,
"[Tags](#cfn-glue-trigger-tags)" : Json,
"[Type](#cfn-glue-trigger-type)" : String,
"[WorkflowName](#cfn-glue-trigger-workflowname)" : String
}
}
Type: AWS::Glue::Trigger
Properties:
[Actions](#cfn-glue-trigger-actions):
- [Action](aws-properties-glue-trigger-action.md)
[Description](#cfn-glue-trigger-description): String
[Name](#cfn-glue-trigger-name): String
[Predicate](#cfn-glue-trigger-predicate):
[Predicate](aws-properties-glue-trigger-predicate.md)
[Schedule](#cfn-glue-trigger-schedule): String
[StartOnCreation](#cfn-glue-trigger-startoncreation): Boolean
[Tags](#cfn-glue-trigger-tags): Json
[Type](#cfn-glue-trigger-type): String
[WorkflowName](#cfn-glue-trigger-workflowname): String
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
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: Json
Update requires: No interruption
Type
The type of trigger that this is.
Required: Yes
Type: String
Update requires: No interruption
WorkflowName
The name of the workflow associated with the trigger.
Required: No
Type: String
Update requires: Replacement
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.
The following example creates an on-demand trigger that triggers one job.
{
"Resources": {
"OnDemandJobTrigger": {
"Type": "AWS::Glue::Trigger",
"Properties": {
"Type": "ON_DEMAND",
"Description": "DESCRIPTION_ON_DEMAND",
"Actions": [
{
"JobName": "prod-job2"
}
],
"Name": "prod-trigger1-ondemand"
}
}
}
}
Resources:
OnDemandJobTrigger:
Type: AWS::Glue::Trigger
Properties:
Type: ON_DEMAND
Description: DESCRIPTION_ON_DEMAND
Actions:
- JobName: prod-job2
Name: prod-trigger1-ondemand
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
.
{
"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"
}
}
}
}
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
The following example creates a conditional trigger that starts a job based on the successful completion of the job run.
{
"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"
}
]
}
}
}
}
}
---
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