简体   繁体   English

使用 boto3 更新触发器 AWS Glue 触发器

[英]Update Trigger AWS Glue Trigger Using boto3

I am attempting to update a trigger to change the job it is triggering.我正在尝试更新触发器以更改它正在触发的作业。 I have referred to the documentation ( https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/glue.html#Glue.Client.get_trigger )我已经参考了文档( https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/glue.html#Glue.Client.get_trigger

My code:我的代码:

# Update the trigger
client.update_trigger(
      Name='myTrigger',
      TriggerUpdate = {
          'Actions': [
              {
                    'JobName': 'JobToTrigger'
              }
          ]
      }
 )

However the resulting error is:然而,由此产生的错误是:

botocore.errorfactory.InvalidInputException: An error occurred (InvalidInputException) when calling the UpdateTrigger operation: botocore.errorfactory.InvalidInputException:调用UpdateTrigger操作时发生错误(InvalidInputException):

I have confirmed that the trigger name is correct as I have used the "get_trigger" call to obtain its details and tried to use that output as a template, but unfortunately to no avail.我已确认触发器名称是正确的,因为我已使用“get_trigger”调用来获取其详细信息并尝试使用 output 作为模板,但不幸的是无济于事。 I assume I have not followed the correct syntax or I am missing a required parameter but unfortunately as you can see the error messaging is fairly vague.我假设我没有遵循正确的语法,或者我缺少必需的参数,但不幸的是,您可以看到错误消息相当模糊。

Any help would be greatly appreciated.任何帮助将不胜感激。

I was able to get your script working by adding schedule to it which seems to be mandatory field.I agree that the error is vague which indicates any thing can be wrong with your input.我可以通过向它添加似乎是必填字段的时间表来使您的脚本正常工作。我同意该错误是模糊的,这表明您的输入可能有任何问题。 Try below script which should update the job details for your trigger.试试下面的脚本,它应该更新触发器的作业详细信息。

If you are not using schedule then try passing appropriate Trigger type.如果您不使用schedule ,请尝试传递适当的触发器类型。

import boto3
from botocore.exceptions import ClientError

session = boto3.session.Session()
glue_client = session.client('glue')
response = glue_client.update_trigger(
    Name='test',
    TriggerUpdate={
        'Name': 'test',
        
        'Schedule': 'cron(15 12 * * ? *)',
        'Actions': [
            {
                'JobName': 'test2'
                },
        ],
    }
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM