How can I be notified when a DataSync task execution succeeds or fails?

Last updated: 2019-08-30

I want to know when my AWS DataSync task execution succeeds or fails. How can I set up notifications for a DataSync task execution? 

Resolution

Configure Amazon Simple Notification Service (Amazon SNS) and Amazon CloudWatch Events to send you an email notification when a DataSync task execution status changes to SUCCESS or ERROR. Follow these steps:

Important: Before you begin, you must have a DataSync agent deployed.

Create an Amazon SNS topic and subscribe your email to the topic

1.    Open the Amazon SNS console.

2.    From the navigation pane, choose Topics.

3.    Choose Create topic.

4.    For Name, enter a name for this topic.

5.    Choose Create topic.

6.    On the page of your newly created topic, choose the Subscriptions tab.

7.    Choose Create subscription.

8.    On the Create subscription page, enter the following:
For Protocol, select Email.
For Endpoint, enter the email address where you want to receive notifications.

9.    Choose Create subscription.

10.    You'll receive a subscription confirmation message at the email address that you specified. Choose the Confirm subscription link in the email message.

Create a CloudWatch Events rule for DataSync and set the SNS topic as the target

1.    Open the CloudWatch console.

2.    From the navigation pane, choose Rules.

3.    Choose Create rule.

4.    Under Event Source, select Event Pattern.

5.    For Service Name, select DataSync.

6.    For Event Type, select DataSync Task Execution State Change.

7.    For Event Pattern Preview, choose Edit. Then, update the JSON code to match the following:

{
  "source": [
    "aws.datasync"
  ],
  "detail-type": [
    "DataSync Task Execution State Change"
  ],
  "detail": {
    "State": [
      "SUCCESS",
      "ERROR"
    ]
  }
}

8.    Choose Save.

9.    Under Targets, choose Add target.

10.    In the dropdown menu, select SNS topic.

11.    For Topic, select the topic that you created.

12.    Choose Configure details.

13.    For Rule definition, enter the following:
For Name, enter a name for this rule.
For Description, enter a description for the rule. Or, you can leave the field blank.
For State, confirm that Enabled is selected.

14.    Choose Create rule.

Start a DataSync task to test email notifications

To test email notifications for Data Sync task execution, you can create a task under a Data Sync agent that's online. Then, start the task.

After you start the task, you'll get an email notification about the status of the DataSync task execution. For a task execution that succeeded, you receive a notification similar to the following:

{"version":"0","id":"example0-c014-d9e9-d7ac-44f00d5d1200","detail-type":"DataSync Task Execution State Change","source":"aws.datasync","account":"111122223333","time":"2019-01-23T12:35:26Z","region":"us-west-2","resources":["arn:aws:sync:us-west-2:9111122223333:task/task-example23d67d5be5/execution/exec-example316440271f"],"detail":{"State":"SUCCESS"}}

Did this article help you?

Anything we could improve?


Need more help?