Need help?

Our experts have had an average response time of 13.52 minutes in October 2021 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 *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF