Unable to deploy a jets app with newly attached jobs. The following resource(s) failed to create: [ConsumeEventSourceMapping, ConsumePermission]

Hello,
Thank you for your great work on the jets framework.
It’s the first time I am using the framework. I created a new app with the API mode and I was able to deploy that without any issue.
However, after adding a job deployment stoped working.

Here’s how my job looks like. After trying the first deployment and it wasn’t successful, I decided to add this iam_policy('sqs') thinking maybe its an IAM permission issue, but that still didn’t work.

class PaymentStatusMessageConsumerJob < ApplicationJob
  sqs_event :generate_queue

  iam_policy('sqs')
  def consume
    puts "consume event #{JSON.dump(event)}"
  end
end

Here’s the error I am getting.

Tidying project: removing ignored files to reduce package size.
=> rsync -a --links /tmp/jets/conectar-message-dispatcher/stage/code/vendor/gems/ruby/2.5.0/ /tmp/jets/conectar-message-dispatcher/stage/opt/ruby/gems/2.5.0/
=> Replacing compiled gems with AWS Lambda Linux compiled versions: /tmp/jets/conectar-message-dispatcher/stage/opt
Checking projects gems for binary Lambda gems…
=> Generating shims in the handlers folder.
Already exists: s3://conectar-message-dispatcher-dev-s3bucket-vuvd0q59d1eq/jets/code/opt-8e5e5296.zip
=> Creating zip file for /tmp/jets/conectar-message-dispatcher/stage/code
=> cd /tmp/jets/conectar-message-dispatcher/stage/code && zip --symlinks -rq code.zip .
Zip file created at: /tmp/jets/conectar-message-dispatcher/stage/zips/code-35586a43.zip (19.9 KB)
Building CloudFormation templates.
Generated CloudFormation templates at /tmp/jets/conectar-message-dispatcher/templates
Uploading CloudFormation templates to S3.
Uploading code zip files to S3.
Uploading /tmp/jets/conectar-message-dispatcher/stage/zips/code-35586a43.zip (19.9 KB) to S3
Uploaded to s3://conectar-message-dispatcher-dev-s3bucket-vuvd0q59d1eq/jets/code/code-35586a43.zip
Time to upload code to s3: 0s
Checking for modified public assets and uploading to S3.
Time for public assets to s3: 0s
Deploying CloudFormation stack with jets app!
Waiting for stack to complete
03:39:16PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack conectar-message-dispatcher-dev User Initiated
03:39:20PM UPDATE_IN_PROGRESS AWS::IAM::Role IamRole
03:39:21PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack ApiGateway
03:39:21PM UPDATE_COMPLETE AWS::CloudFormation::Stack ApiGateway
03:39:23PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack ApiResources1
03:39:23PM UPDATE_COMPLETE AWS::CloudFormation::Stack ApiResources1
03:39:37PM UPDATE_COMPLETE AWS::IAM::Role IamRole
03:39:39PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack PaymentStatusMessageConsumerJob
03:39:39PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack JetsPublicController
03:39:39PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack JetsPreheatJob
03:39:39PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack PaymentStatusMessageConsumerJob Resource creation Initiated
03:39:50PM UPDATE_COMPLETE AWS::CloudFormation::Stack JetsPublicController
03:39:51PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiDeployment20200603153912
03:39:52PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiDeployment20200603153912 Resource creation Initiated
03:40:02PM CREATE_COMPLETE AWS::CloudFormation::Stack ApiDeployment20200603153912
03:40:13PM CREATE_FAILED AWS::CloudFormation::Stack PaymentStatusMessageConsumerJob Embedded stack arn:aws:cloudformation:eu-central-1:949696328322:stack/conectar-message-dispatcher-dev-PaymentStatusMessageConsumerJob-1XSOVVSJ4CNG6/4a580a70-a597-11ea-9a0c-064768627800 was not successfully created: The following resource(s) failed to create: [ConsumeEventSourceMapping, ConsumePermission].
03:40:13PM UPDATE_COMPLETE AWS::CloudFormation::Stack JetsPreheatJob
03:40:14PM UPDATE_ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack conectar-message-dispatcher-dev The following resource(s) failed to create: [PaymentStatusMessageConsumerJob].
03:40:17PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack ApiGateway
03:40:17PM UPDATE_IN_PROGRESS AWS::IAM::Role IamRole
03:40:17PM UPDATE_COMPLETE AWS::CloudFormation::Stack ApiGateway
03:40:18PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack ApiResources1
03:40:18PM UPDATE_COMPLETE AWS::CloudFormation::Stack ApiResources1
03:40:33PM UPDATE_COMPLETE AWS::IAM::Role IamRole
03:40:34PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack JetsPreheatJob
03:40:34PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack JetsPublicController
03:40:45PM UPDATE_COMPLETE AWS::CloudFormation::Stack JetsPublicController
03:41:08PM UPDATE_COMPLETE AWS::CloudFormation::Stack JetsPreheatJob
03:41:09PM UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS AWS::CloudFormation::Stack conectar-message-dispatcher-dev
03:41:10PM DELETE_IN_PROGRESS AWS::CloudFormation::Stack ApiDeployment20200603153912
03:41:10PM DELETE_IN_PROGRESS AWS::CloudFormation::Stack PaymentStatusMessageConsumerJob
03:41:20PM UPDATE_COMPLETE AWS::CloudFormation::Stack JetsPreheatJob
03:41:21PM DELETE_COMPLETE AWS::CloudFormation::Stack ApiDeployment20200603153912
03:41:32PM UPDATE_COMPLETE AWS::CloudFormation::Stack JetsPublicController
03:41:32PM UPDATE_COMPLETE AWS::CloudFormation::Stack ApiResources1
03:41:33PM UPDATE_COMPLETE AWS::CloudFormation::Stack ApiGateway
03:42:28PM DELETE_COMPLETE AWS::CloudFormation::Stack PaymentStatusMessageConsumerJob
03:42:28PM UPDATE_ROLLBACK_COMPLETE AWS::CloudFormation::Stack conectar-message-dispatcher-dev
Stack rolled back: UPDATE_ROLLBACK_COMPLETE
Time took for stack deployment: 3m 13s.
The Jets application failed to deploy. Jets creates a few CloudFormation stacks to deploy your application.
The logs above show the CloudFormation parent stack events and points to the stack with the error.
Please go to the CloudFormation console and look for the specific stack with the error.
The specific child stack usually shows more detailed information and can be used to resolve the issue.
Example of checking the CloudFormation console: https://rubyonjets.com/docs/debugging/cloudformation/

I have checked the cloud formation nested stack and checked the logs as stated in the docs here - https://rubyonjets.com/docs/debugging/cloudformation/ I see the same thing.
What is missing, I am sure it is probably some extra configuration that is missing in the documentation. Please put me through.

Here’s the screenshot of the logs on AWS console.

Thanks.

I found the fix for this issue.
I was missing the class_timeout 30 in the code. I also got another error when I didn’t add the Job to the name of my class and file.

Here’s the code that finally worked for me.

class PaymentStatusMessageConsumerJob < ApplicationJob
  class_timeout 30 # must be less than or equal to the SQS queue default timeout
  sqs_event :generate_queue

  def consume_message
    puts "lift event #{JSON.dump(event)}"
  end
end
1 Like