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

Last updated: 2021-12-20

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 EventsBridge 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 already created a DataSync task.

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

1.    Open the Amazon SNS console.

2.    In 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 an EventBridge rule for DataSync and set the SNS topic as the target

1.    Open the Amazon EventBridge console.

2.    In the navigation pane, choose Rules.

3.    Choose Create rule.

4.    Enter a name and description for the rule.

5.    For Define pattern, select Event pattern.

6.    For Event matching pattern, select Pre-defined pattern by service.

7.    For Service provider, select AWS.

8.    For Service name, select Datasync.

9.    For Event type, select Datasync Task Execution State Change.

10.    Under Event pattern, copy and paste the following JSON code:

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

11.    Under Select Targets, do the following:

For Target, select SNS topic.

For Topic, select the topic that you created.

12.    Choose Create.

Start a DataSync task to test email notifications

To test email notifications for DataSync task execution, first create a task, and 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?


Do you need billing or technical support?