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:
- We have to open the AWS Batch console.
- Then we have to select the AWS Region from the navigation bar.
- After that, we will select Job definitions followed by Create in the navigation pane.
- Next, we have to enter a unique name for the job definition in the Job definition name section.
- Then, enter amazonlinux for Container image.
- After that, enter the following for Command:
echo Ref::S3bucket
- Next, we have to enter “2” for vCPUs and “500” from Memory(MiB).
- Finally, click Next and select Create.
How to get ARN of job queue & job definition?
- First, we will open the AWS Batch console.
- Then, we have to select Job queues in the navigation pane.
- After that, we will select the job queue.
- Next, we have to head to the Overview section and copy the Queue ARN for later.
- Then, we have to select Job definitions in the navigation pane and choose the previously created job definition.
- 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
- First, we have to open the CloudWatch console.
- Then, we will select Rules followed by Create rule in the navigation pane.
- After that, we will select Event Pattern in the Event Source section.
- Next, we will choose Simple Storage Service (S3) for Service Name.
- Then, we have to choose Bucket Level Operations for the Event type.
- After that, we have to select Any operation.
- At this point, we will choose Add target in the Targets section.
- Then, we will go to the main menu and select Batch job queue.
- Here, we have to paste the job queue ARN number and job definition ARN in the Job queue and Job definition section respectively.
- After that, we have to enter a name for the AWS batch job for Job name.
- Next, we will select Input Transformer in the Configure input section.
- 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.
- 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.
- Next, we will select either Use existing role or Create a new role for this specific resource.
- Then, select Configure details.
- After that, we will enter the name of the rule for Name and select the Enabled checkbox for State.
- Finally, we will select Create rule.
How to test newly created rule
- First, we will open the Amazon S3 console.
- Next, we have to select Create bucket.
- After that, we have to enter a unique DNS-compliant name for the new bucket in the Bucket name field.
- Then, we will select the same Region where the new CloudWatch Events rule was created for the Region.
- Finally, we will choose Create.
How to check the logs
- First, open the AWS Batch console.
- Then, select Jobs in the navigation pane.
- After that, we will select the job which has SUCCEEDED as the Status.
- 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.
0 Comments