wesupport

Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

AWS Batch as target for CloudWatch Events rule | How-to-guide

by | Nov 25, 2021

AWS Batch as target for CloudWatch Events rule is no longer a problem with Bobcares by your side. 

At Bobcares, we offer solutions for every query, big and small, as a part of our AWS Support Service.

Let’s take a look at how our Support Team recently helped a customer use AWS Batch as a target for the CloudWatch Events rule.

How to use AWS Batch as a target for CloudWatch Events rule

Our Support Engineers have created this handy guide to help you use AWS Batch as a target for your Amazon CloudWatch Events rule.

This process illustrates how to configure Amazon CloudWatch in order to submit an AWS Batch job when a brand new Amazon S3 bucket is created.

First we need to create a job definition with these steps:

  1. We have to open the AWS Batch console.
  2. Then we have to select the AWS Region from the navigation bar.
  3. After that, we will select Job definitions followed by Create in the navigation pane.
  4. Next, we have to enter a unique name for the job definition in the Job definition name section.
  5. Then, enter amazonlinux for Container image.
  6. After that, enter the following for Command:
    echo Ref::S3bucket
  7. Next, we have to enter “2” for vCPUs and “500” from Memory(MiB).
  8. Finally, click Next and select Create.

How to get ARN of job queue & job definition?

  1. First, we will open the AWS Batch console.
  2. Then, we have to select Job queues in the navigation pane.
  3. After that, we will select the job queue.
  4. Next, we have to head to the Overview section and copy the Queue ARN for later.
  5. Then, we have to select Job definitions in the navigation pane and choose the previously created job definition.
  6. After that, we have to copy the Job definition ARN in the Job definitions attributes section and save it for later.

How to create a CloudWatch Events rule

  1. First, we have to open the CloudWatch console.
  2. Then, we will select Rules followed by Create rule in the navigation pane.
  3. After that, we will select Event Pattern in the Event Source section.
  4. Next, we will choose Simple Storage Service (S3) for Service Name.
  5. Then, we have to choose Bucket Level Operations for the Event type.
  6. After that, we have to select Any operation.
  7. At this point, we will choose Add target in the Targets section.
  8. Then, we will go to the main menu and select Batch job queue.
  9. Here, we have to paste the job queue ARN number and job definition ARN in the Job queue and Job definition section respectively.
  10. After that, we have to enter a name for the AWS batch job for Job name.
  11. Next, we will select Input Transformer in the Configure input section.
  12. Then, we have to enter the S3 bucket values that will be sent when the event gets triggered in the first input box:
    {"S3BucketNameValue":"$.detail.requestParameters.bucketName"}

    Remember to replace S3BucketNameValue with the required value.

  13. After that, we have to enter the Parameters structure that will be passed on to the Batch job in the second input box:
    {"Parameters" : {"S3bucket": S3BucketNameValue}}

    Remember to replace S3BucketNameValue and S3bucket with the appropriate values.

  14. Next, we will select either Use existing role or Create a new role for this specific resource.
  15. Then, select Configure details.
  16. After that, we will enter the name of the rule for Name and select the Enabled checkbox for State.
  17. Finally, we will select Create rule.

How to test newly created rule

  1. First, we will open the Amazon S3 console.
  2. Next, we have to select Create bucket.
  3. After that, we have to enter a unique DNS-compliant name for the new bucket in the Bucket name field.
  4. Then, we will select the same Region where the new CloudWatch Events rule was created for the Region.
  5. Finally, we will choose Create.

How to check the logs

  1. First, open the AWS Batch console.
  2. Then, select Jobs in the navigation pane.
  3. After that, we will select the job which has SUCCEEDED as the Status.
  4. Then, we will head to the Attempts section and select Vire logs on the Job details page. The log will display the bucket name in the CloudWatch console.

[Need further assistance? We are available 24/7.]

Conclusion

To sum up, the skilled Support Engineers at Bobcares demonstrated how to use AWS Batch as target for CloudWatch Events rule.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags