12

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:

enter image description here

Is there a way to define an activated scheduled trigger alone via CloudFormation?

Andrey Cheptsov
  • 541
  • 5
  • 14

2 Answers2

13

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
Gregory Posey
  • 146
  • 1
  • 2
  • 5
    Nice, thanks! I will add that as the property says only work for NEW triggers only. Existing triggers will not change from CREATED to ACTIVATED if StartOnCreation is added to CF. – Luis Galvez Jun 22 '20 at 23:15
6

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

JustinJ
  • 69
  • 1
  • 3
    November 2018 and still no way to activate by default or set to active via CloudFormation. Custom resource with a Lambda function is still the best bet. – ncarmona Nov 27 '18 at 18:10
  • outdated answer. Refer to answer https://stackoverflow.com/a/58381166/6368240 given by Gregory Posey – Srini Nov 22 '19 at 19:02