How do I automate AWS DMS tasks for specific time intervals?

2 minute read
0

I want to automate AWS Database Migration Service (AWS DMS) tasks for specific time intervals. Or, I want to automatically start and stop DMS tasks.

Resolution

To automate AWS DMS tasks for specific time intervals, use an Amazon EventBridge rule to start the task.

To use an EventBridge rule to automate DMS tasks, complete the following steps:

  1. Create a DMS task. Or, if you have an existing DMS task, modify the EventBridge rule based on the task status.

  2. Open the EventBridge console.

  3. In the navigation pane, choose Schedules, and then choose Create schedule.

  4. On the Specify schedule detail page, enter the following details for your schedule:
    For Schedule Name and Description, enter your information.
    For Schedule group, choose Default.
    For Schedule pattern, choose One time or Recurring.

  5. Choose Next.

  6. Under Target detail, for Target API, select All APIs.

  7. In the All AWS services field, enter AWS Database Migration. When the AWS Database Migration option appears, choose it.

  8. In the Find API field, enter StartReplicationTask. When the StartReplicationTask option appears, choose it.

  9. For the JSON input, provide your DMS task ARN. For StartReplicationTaskType, enter resume-processing. For more information, see StartReplicationTask.
    Note: When the migration type is full-load or full-load-and-cdc, the only value for the first run of the task is start-replication. This option starts the migration.

  10. For Retry policy, DLQ, and Encryption, update these values based on your requirements.

  11. Choose Next.

  12. For Permissions, attach an AWS Identity and Access Management (IAM) role with permissions to run the schedule and start a DMS task. Then, choose Next.
    Example IAM policy trust relationship:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {
            "Service": [
              "scheduler.amazonaws.com",
              "apidestinations.events.amazonaws.com"
            ]
          },
          "Action": "sts:AssumeRole"
        }
      ]
    }

    The following example policy provides full DMS access. Configure your access based on your requirements.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "VisualEditor0",
          "Effect": "Allow",
          "Action": "dms:*",
          "Resource": "*"
        }
      ]
    }
  13. Choose Create schedule.

You can use Amazon CloudWatch or AWS CloudTrail to monitor the EventBridge rule.

Related information

Automating AWS DMS migration tasks

Automating database migration and refreshing activities with AWS DMS

Working with AWS DMS tasks

AWS OFFICIAL
AWS OFFICIALUpdated 15 days ago