72 AWS Batch User Guide Tutorial Sending Amazon Simple Notification Service

72 aws batch user guide tutorial sending amazon

This preview shows page 77 - 80 out of 91 pages.

72
Image of page 77
AWS Batch User Guide Tutorial: Sending Amazon Simple Notification Service Alerts for Failed Job Events Tutorial: Sending Amazon Simple Notification Service Alerts for Failed Job Events In this tutorial, you configure a CloudWatch Events event rule that only captures job events where the job has moved to a FAILED status. At the end of this tutorial, you can submit a job to this job queue to test that you have configured your Amazon SNS alerts correctly. Prerequisites This tutorial assumes that you have a working compute environment and job queue that are ready to accept jobs. If you do not have a running compute environment and job queue to capture events from, follow the steps in Getting Started with AWS Batch (p. 9) to create one. Step 1: Create and Subscribe to an Amazon SNS Topic For this tutorial, you configure an Amazon SNS topic to serve as an event target for your new event rule. To create an Amazon SNS topic 1. Open the Amazon SNS console at . 2. Choose Topics , Create new topic . 3. For Topic name , enter JobFailedAlert and choose Create topic . 4. Select the topic that you just created. On the Topic details: JobFailedAlert screen, choose Create subscription . 5. For Protocol , choose Email . For Endpoint , enter an email address to which you currently have access and choose Create subscription . 6. Check your email account, and wait to receive a subscription confirmation email message. When you receive it, choose Confirm subscription . Step 2: Register Event Rule Next, register an event rule that captures only job-failed events. To create an event rule 1. Open the CloudWatch console at . 2. In the navigation pane, choose Events , Create rule . 3. Choose Show advanced options , edit . 4. For Build a pattern that selects events for processing by your targets , replace the existing text with the following text: { "detail-type": [ "Batch Job State Change" ], "source": [ "aws.batch" ], "detail": { "status": [ "FAILED" ] 73
Image of page 78
AWS Batch User Guide Step 3: Test Your Rule } } This code defines a CloudWatch Events rule that matches any event where the job status is FAILED . For more information about event patterns, see Events and Event Patterns in the Amazon CloudWatch User Guide . 5. For Targets , choose Add target . For Target type , choose SNS topic , JobFailedAlert . 6. Choose Configure details . 7. For Rule definition , type a name and description for your rule and then choose Create rule . Step 3: Test Your Rule To test your rule, submit a job that exits shortly after it starts with a non-zero exit code. If your event rule is configured correctly, you receive an email message within a few minutes with the event text. To test a rule 1. Open the AWS Batch console at . 2. Submit a new AWS Batch job. For more information, see Submitting a Job (p. 13) . For the job's command, substitute this command to exit the container with an exit code of 1.
Image of page 79
Image of page 80

You've reached the end of your free preview.

Want to read all 91 pages?

  • Spring '17
  • A.D.P.
  • ........., Amazon Web Services, AWS, Amazon Elastic Compute Cloud

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture