AWS CloudFormation
User Guide (API 版本 2010-05-15)
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 Amazon AWS 入门

AWS::Glue::Trigger

AWS::Glue::Trigger 资源指定运行 AWS Glue 作业的触发器。有关更多信息,请参阅 AWS Glue 开发人员指南 中的在 AWS Glue 中触发作业Trigger 结构

语法

要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:

JSON

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

YAML

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

属性

Type

作业触发器的类型。有效值为 SCHEDULEDCONDITIONALON_DEMAND

必需:是

类型:字符串

更新要求无需中断

Description

作业触发器的描述。

必需:否

类型:字符串

更新要求无需中断

Actions

在触发作业触发器时启动的操作。

必需:是

类型AWS Glue Trigger Action 的列表

更新要求无需中断

Schedule

作业触发器的 cron 计划表达式。

必需:否

类型:字符串

更新要求无需中断

Name

作业触发器的名称。

必需:否

类型:字符串

更新要求替换

Predicate

作业触发器的谓词,它确定何时触发该触发器。

必需:否

类型AWS Glue Trigger Predicate

更新要求无需中断

返回值

Ref

当该资源的逻辑 ID 提供给 Ref内部函数时,Ref 将返回资源名称。

有关使用 Ref 功能的更多信息,请参阅参考

示例

按需触发器

以下示例创建触发一个作业的按需触发器。

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

计划触发器

以下示例创建一个计划触发器,它每两小时运行一次并触发两个作业。请注意,它为 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

条件触发器

以下示例创建一个条件触发器,它根据是否成功完成作业运行来启动作业。

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

--- 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

本页内容: