Setting class level dead letter config with a shared resource

I was going to post this as a Github issue but I think I’m just doing something wrong. I have a fairly simple ApplicationJob that looks like:

class ApplicationJob < Jets::Job::Base
  depends_on :dead_letter_queue

  # Adjust to increase the default timeout for all Job classes
  class_timeout 60

  # **** Dead letter config that seems to be causing problems ****
  class_dead_letter_config ref(:dead_letter)
end

However, this fails to create a job that inherits from ApplicationJob, because it says: Template format error: Unresolved resource dependencies [DeadLetter] in the Resources block of the template.

The shared resource is very simple:

class DeadLetterQueue < Jets::Stack
  sqs_queue(:dead_letter)
end

Any suggestions are welcomed!

Guessing the depends_on DSL keyword is not accounting for inheritance currently. If that’s the case will have to fix. A workaround is probably to move depends_on to the concrete Job class itself for now.

Note: Didnt test any of this theory because am on the go, but figure it may be a good clue.

For some reason, I had to do two things: 1) move depends_on and the config to the child class like you mentioned, and 2) supply a hash with target_arn as the key. This syntax worked:

class ProcessUploadJob < ApplicationJob
  depends_on :dead_letter_queue
  
  class_timeout 900
  class_dead_letter_config({ target_arn: ref(:dead_letter) })

  # . . . etc . . .
end
1 Like

Makes sense. Its because the dead_letter_config property requires that structure https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-deadletterconfig.html

Could decorate the method to make both forms work. Will consider PRs for it. No sweat either way of course. Will dig into in time.

Ahhh good point. I saw that syntax on the function config in the boilerpate application.rb so I replicated. Thanks for the help! Might just make sense to document that rather than accept both forms.

Cool. Docs sound good!