I'm using CloudFormation to define a SCHEDULED
Glue job trigger according to the official documentation:
ParquetJobTrigger:
Type: 'AWS::Glue::Trigger'
Properties:
Name: !Sub "${Prefix}_csv_to_parquet_job_trigger_${StageName}"
Type: SCHEDULED
Schedule: cron(0 0/1 * * ? *)
Actions:
- JobName: !Ref ParquetJob
Arguments:
"--job-bookmark-option": "job-bookmark-enable"
It works like a charm except one thing. It defines a job trigger that has a status CREATED
and I have to manually enable it:
Is there a way to define an activated scheduled trigger alone via CloudFormation?
For anyone new looking, this can be achieved now by using the StartOnCreation property for new triggers.
UEDDBJobTrigger:
Type: AWS::Glue::Trigger
Properties:
Name: Foo
Description: Scheduled trigger
Type: SCHEDULED
Schedule: "cron(0 10 ? * MON-FRI *)"
StartOnCreation: true
Actions:
- JobName: !Ref TestJob
Had the same issue and opened up a ticket with AWS. Looks like they currently do not have the feature but are looking to address in their next feature release. Below is their response:
Thank you for contacting AWS premium support. It was a pleasure speaking with you today. I am writing back to followup on our conversation. I was able to get in touch with members of the Glue team and the Cloud Formation team following are my findings:
1) It looks like there isn't away to enable the Glue trigger using the resource namespace: AWS::Glue::Trigger
2) The scheduled jobs should retry on the next scheduled time if the first time it does so fails
3) As a work around to the above, what you could do is have the scheduled actions trigger a certain length of time after the stack is created in order for you to manually enable the trigger through the web console.
4) As discussed during our call, it looks like a Lambda function could in fact be feasible. In this case you can have the Lambda Function depend on the Trigger resource and then make the API call start-trigger (https://docs.aws.amazon.com/cli/latest/reference/glue/start-trigger.html) using the lambda function to enable the trigger. These actions should occur in time for the scheduled jobs to be triggered.
Following are some useful references for Lambda and Cloud Formation: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/walkthrough-custom-resources-lambda-lookup-amiids.html https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With