

# Getting started with AWS Database Migration Service
<a name="CHAP_GettingStarted"></a>

In the following tutorial, you can find out how to perform a database migration with AWS Database Migration Service (AWS DMS).

To perform a database migration, take the following steps:

1. Set up your AWS account by following the steps in [Set up for AWS Database Migration Service](CHAP_GettingStarted.SettingUp.md).

1. Create your sample databases and an Amazon EC2 client to populate your source database and test replication. Also, create a virtual private cloud (VPC) based on the Amazon Virtual Private Cloud (Amazon VPC) service to contain your tutorial resources. To create these resources, follow the steps in [Complete prerequisites to set up AWS Database Migration Service](CHAP_GettingStarted.Prerequisites.md).

1. Populate your source database using a [sample database creation script](https://github.com/aws-samples/aws-database-migration-samples). 

1. Use DMS Schema Conversion to convert the schema from the source database to the target database. Follow the steps in [Getting started with DMS Schema Conversion](getting-started.md). Alternatively, if you are using the legacy AWS Schema Conversion Tool (AWS SCT), follow the steps in [Migrate schema](CHAP_GettingStarted.SCT.md).

1. Create a replication instance to perform all the processes for the migration. To do this and the following tasks, take the steps in [Replication](CHAP_GettingStarted.Replication.md).

1. Specify source and target database endpoints. For information about creating endpoints, see [Creating source and target endpoints](CHAP_Endpoints.Creating.md).

1. Create a task to define what tables and replication processes you want to use, and start replication. For information about creating database migration tasks, see [Creating a task](CHAP_Tasks.Creating.md).

1. Verify that replication is working by running queries on the target database.

## Learn more about working with AWS Database Migration Service
<a name="CHAP_GettingStarted.References"></a>

Later in this guide, you can learn how to use AWS DMS to migrate your data to and from the most widely used commercial and open-source databases. 

We also recommend that you check the following resources as you prepare and perform a database migration project:
+ [AWS DMS Step-by-Step Migration Guide](https://docs.aws.amazon.com/dms/latest/sbs/DMS-SBS-Welcome.html) – This guide provides step-by-step walkthroughs that go through the process of migrating data to AWS.
+ [AWS DMS API Reference](https://docs.aws.amazon.com/dms/latest/APIReference/Welcome.html) – This reference describes all the API operations for AWS Database Migration Service in detail.
+ [AWS CLI for AWS DMS](https://docs.aws.amazon.com/cli/latest/reference/dms/index.html) – This reference provides information about using the AWS Command Line Interface (AWS CLI) with AWS DMS.

# Set up for AWS Database Migration Service
<a name="CHAP_GettingStarted.SettingUp"></a>

## Sign up for an AWS account
<a name="sign-up-for-aws"></a>

If you do not have an AWS account, complete the following steps to create one.

**To sign up for an AWS account**

1. Open [https://portal.aws.amazon.com/billing/signup](https://portal.aws.amazon.com/billing/signup).

1. Follow the online instructions.

   Part of the sign-up procedure involves receiving a phone call or text message and entering a verification code on the phone keypad.

   When you sign up for an AWS account, an *AWS account root user* is created. The root user has access to all AWS services and resources in the account. As a security best practice, assign administrative access to a user, and use only the root user to perform [tasks that require root user access](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#root-user-tasks).

AWS sends you a confirmation email after the sign-up process is complete. At any time, you can view your current account activity and manage your account by going to [https://aws.amazon.com/](https://aws.amazon.com/) and choosing **My Account**.

## Create a user with administrative access
<a name="create-an-admin"></a>

After you sign up for an AWS account, secure your AWS account root user, enable AWS IAM Identity Center, and create an administrative user so that you don't use the root user for everyday tasks.

**Secure your AWS account root user**

1.  Sign in to the [AWS Management Console](https://console.aws.amazon.com/) as the account owner by choosing **Root user** and entering your AWS account email address. On the next page, enter your password.

   For help signing in by using root user, see [Signing in as the root user](https://docs.aws.amazon.com/signin/latest/userguide/console-sign-in-tutorials.html#introduction-to-root-user-sign-in-tutorial) in the *AWS Sign-In User Guide*.

1. Turn on multi-factor authentication (MFA) for your root user.

   For instructions, see [Enable a virtual MFA device for your AWS account root user (console)](https://docs.aws.amazon.com/IAM/latest/UserGuide/enable-virt-mfa-for-root.html) in the *IAM User Guide*.

**Create a user with administrative access**

1. Enable IAM Identity Center.

   For instructions, see [Enabling AWS IAM Identity Center](https://docs.aws.amazon.com//singlesignon/latest/userguide/get-set-up-for-idc.html) in the *AWS IAM Identity Center User Guide*.

1. In IAM Identity Center, grant administrative access to a user.

   For a tutorial about using the IAM Identity Center directory as your identity source, see [ Configure user access with the default IAM Identity Center directory](https://docs.aws.amazon.com//singlesignon/latest/userguide/quick-start-default-idc.html) in the *AWS IAM Identity Center User Guide*.

**Sign in as the user with administrative access**
+ To sign in with your IAM Identity Center user, use the sign-in URL that was sent to your email address when you created the IAM Identity Center user.

  For help signing in using an IAM Identity Center user, see [Signing in to the AWS access portal](https://docs.aws.amazon.com/signin/latest/userguide/iam-id-center-sign-in-tutorial.html) in the *AWS Sign-In User Guide*.

**Assign access to additional users**

1. In IAM Identity Center, create a permission set that follows the best practice of applying least-privilege permissions.

   For instructions, see [ Create a permission set](https://docs.aws.amazon.com//singlesignon/latest/userguide/get-started-create-a-permission-set.html) in the *AWS IAM Identity Center User Guide*.

1. Assign users to a group, and then assign single sign-on access to the group.

   For instructions, see [ Add groups](https://docs.aws.amazon.com//singlesignon/latest/userguide/addgroups.html) in the *AWS IAM Identity Center User Guide*.

# Complete prerequisites to set up AWS Database Migration Service
<a name="CHAP_GettingStarted.Prerequisites"></a>

In this section, you can learn the prerequisite tasks for AWS DMS, such as setting up your source and target databases. As part of these tasks, you also set up a virtual private cloud (VPC) based on the Amazon VPC service to contain your resources. In addition, you set up an Amazon EC2 instance that you use to populate your source database and verify replication on your target database.

**Note**  
Populating the source database takes up to 45 minutes.

For this tutorial, you create a MariaDB database as your source, and a PostgreSQL database as your target. This scenario uses commonly used, low-cost database engines to demonstrate replication. Using different database engines demonstrates AWS DMS features for migrating data between heterogeneous platforms.

The resources in this tutorial use the US West (Oregon) Region. If you want to use a different AWS Region, specify your chosen Region instead wherever US West (Oregon) appears.

**Note**  
For the sake of simplicity, the databases that you create for this tutorial don't use encryption or other advanced security features. You must use security features to keep your production databases secure. For more information, see [Security in Amazon RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.html).

For prerequisite steps, see the following topics.

**Topics**
+ [Create a VPC](#CHAP_GettingStarted.Prerequisites.VPC)
+ [Create Amazon RDS parameter groups](#CHAP_GettingStarted.Prerequisites.params)
+ [Create your source Amazon RDS database](#CHAP_GettingStarted.Prerequisites.sdatabase)
+ [Create your target Amazon RDS database](#CHAP_GettingStarted.Prerequisites.tdatabase)
+ [Create an Amazon EC2 client](#CHAP_GettingStarted.Prerequisites.client)
+ [Populate your source database](#CHAP_GettingStarted.Prerequisites.Populate)

## Create a VPC
<a name="CHAP_GettingStarted.Prerequisites.VPC"></a>

In this section, you create a VPC to contain your AWS resources. Using a VPC is a best practice when using AWS resources, so that your databases, Amazon EC2 instances, security groups, and so on, are logically organized and secure. 

Using a VPC for your tutorial resources also ensures that you delete all of the resources you use when you are done with the tutorial. You must delete all of the resources that a VPC contains before you can delete the VPC.

**To create a VPC for use with AWS DMS**

1. Sign in to the AWS Management Console and open the Amazon VPC console at [https://console.aws.amazon.com/vpc/](https://console.aws.amazon.com/vpc/).

1. On the navigation pane, choose **VPC Dashboard**, and then choose **Create VPC**.

1. On the **Create VPC** page, enter the following options:
   + **Resources to create**: **VPC and more**
   + **Name tag auto generation**: Choose **Auto-generate**, and enter **DMSVPC**.
   + **IPv4 block**: **10.0.1.0/24**
   + **IPv6 CIDR block**: **No IPv6 CIDR block**
   + **Tenancy**: **Default**
   + **Number of availability zones**: 2
   + **Number of public subnets**: 2
   + **Number of private subnets**: 2
   + **NAT gateways (\$1)**: **None**
   + **VPC endpoints**: **None**

   Choose **Create VPC**.

1. On the navigation pane, choose **Your VPCs**. Note the VPC ID for **DMSVPC**.

1. On the navigation pane, choose **Security Groups**. 

1. Choose the group named **default** that has a **VPC ID** that matches the ID that you noted for **DMSVPC**.

1. Choose the **Inbound rules** tab, and choose **Edit inbound rules**.

1. Choose **Add rule**. Add a rule of type **MySQL/Aurora** and choose **Anywhere-IPv4** for **Source**. 

1. Choose **Add rule** again. Add a rule of type **PostgreSQL** and choose **Anywhere-IPv4** for **Source**.

1. Choose **Save rules**.

## Create Amazon RDS parameter groups
<a name="CHAP_GettingStarted.Prerequisites.params"></a>

To specify settings for your source and target databases for AWS DMS, use Amazon RDS parameter groups. To allow initial and ongoing replication between your databases, make sure to configure the following:
+ Your source database's binary log, so that AWS DMS can determine what incremental updates it needs to replicate.
+ Your target database's replication role, so that AWS DMS ignores foreign key constraints during the initial data transfer. With this setting, AWS DMS can migrate data out of order.

**To create parameter groups for use with AWS DMS**

1. Open the Amazon RDS console at [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/).

1. On the navigation pane, choose **Parameter groups**.

1. On the **Parameter groups** page, choose **Create parameter group**.

1. On the **Create parameter group** page, enter the following settings:
   + **Parameter group family**: **mariadb10.6**
   + **Group name**: **dms-mariadb-parameters**
   + **Description**: **Group for specifying binary log settings for replication**

   Choose **Create**.

1. On the **Parameter groups** page, choose **dms-mariadb-parameters**, and on the **dms-mariadb-parameters** page, choose **Edit**.

1. Set the following parameters to the following values:
   + **binlog\$1checksum**: **NONE**
   + **binlog\$1format**: **ROW**

   Choose **Save changes**.

1. On the **Parameter groups** page, choose **Create parameter group** again.

1. On the **Create parameter group** page, enter the following settings:
   + **Parameter group family**: **postgres16**
   + **Group name**: **dms-postgresql-parameters**
   + **Description**: **Group for specifying role setting for replication**

   Choose **Create**.

1. On the **Parameter groups** page, choose **dms-postgresql-parameters**.

1. On the **dms-postgresql-parameters** page, choose **Edit**, and set **session\$1replication\$1role parameter** to **replica**. Note that the **session\$1replication\$1role ** parameter is not on the first page of parameters. Use the pagination controls or the search field to find the parameter.

1. Choose **Save changes**.

## Create your source Amazon RDS database
<a name="CHAP_GettingStarted.Prerequisites.sdatabase"></a>

Use the following procedure to create your source Amazon RDS database.

**To create your source Amazon RDS for MariaDB database**

1. Open the Amazon RDS console at [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/).

1. On the **Dashboard** page, choose **Create Database** in the **Database** section. Don't choose **Create Database** in the **Try the new Amazon RDS Multi-AZ deployment option for MySQL and PostgreSQL** section at the top of the page.

1. On the **Create database** page, set the following options:
   + **Choose a database creation method**: Choose **Standard Create**.
   + **Engine options**: For **Engine type**, choose **MariaDB**. For **Version**, leave **MariaDB 10.6.14** selected.
   + **Templates**: Choose **Dev/Test**.
   + **Settings**: 
     + **DB instance identifier**: Enter **dms-mariadb**.
     + In the **Credentials settings** section, enter the following:
       + **Master username**: Leave as **admin**.
       + Leave **Manage master credentials in AWS Secrets Manager** unchecked.
       + **Auto generate a password**: Leave unselected.
       + **Master password**: Enter **changeit**.
       + **Confirm password**: Enter **changeit** again.
   + **Instance configuration**: 
     + **DB instance class**: Leave **Standard classes** chosen.
     + For **DB instance class**, choose **db.m5.large**.
   + **Storage**: 
     + Clear the **Enable storage autoscaling** box.
     + Leave the rest of the settings as they are.
   + **Availability and Durability**: Leave **Do not create a standby instance** selected.
   + **Connectivity**:
     + **Compute resource** Leave **Don't connect to an EC2 compute resource**
     + **Network type**: Leave **IPv4** selected.
     + **Virtual private cloud**: **DMSVPC-vpc**
     + **Public access**: **Yes**. You must enable public access to use the AWS Schema Conversion Tool.
     + **Availability zone**: **us-west-2a**
     + Leave the rest of the settings as they are.
   + **Database authentication**: Leave **Password authentication** selected.
   + Under **Monitoring**, clear the **Turn on Performance Insights** box. Expand the **Additional configuration** section, and clear the **Enable Enhanced monitoring** box.
   + Expand **Additional configuration**:
     + Under **Database options**, enter **dms\$1sample** for **Initial database name**. 
     + Under **DB parameter group**, choose **dms-mariadb-parameters**.
     + For **Option group**, leave **default:mariadb-10-6** selected.
     + Under **Backup**, do the following:
       + Leave **Enable automatic backups** selected. Your source database must have automatic backups enabled to support ongoing replication.
       + For **Backup retention period**, choose **1 day**.
       + For **Backup window**, leave **No preference** selected.
       + Clear the **Copy tags to snapshots** box.
       + Leave the **Enable replication in another AWS region** unchecked.
     + Under **Encryption**, clear the **Enable encryption** box.
     + Leave the **Log exports** section as it is.
     + Under **Maintenance**, clear the **Enable auto minor version upgrade** box, and leave the **Maintenance window** setting as **No preference**.
     + Leave **Enable deletion protection** unchecked.

1. Choose **Create database**.

## Create your target Amazon RDS database
<a name="CHAP_GettingStarted.Prerequisites.tdatabase"></a>

Repeat the previous procedure to create your target Amazon RDS database, with the following changes.

**To create your target RDS for PostgreSQL database**

1. Repeat steps 1 and 2 from the previous procedure. 

1. On the **Create database** page, set the same options, except for these:

   1. For **Engine options**, choose **PostgreSQL**.

   1. For **Version**, choose an available **PostgreSQL 16** version

   1. For **DB instance identifier**, enter **dms-postgresql**.

   1. For **Master username**, leave **postgres** selected.

   1. For **DB parameter group**, choose **dms-postgresql-parameters**.

   1. Clear **Enable automatic backups**.

1. Choose **Create database**.

## Create an Amazon EC2 client
<a name="CHAP_GettingStarted.Prerequisites.client"></a>

In this section, you create an Amazon EC2 client. You use this client to populate your source database with data to replicate. You also use this client to verify replication by running queries on the target database.

Using an Amazon EC2 client to access your databases provides the following advantages over accessing your databases over the internet:
+ You can restrict access to your databases to clients that are in the same VPC.
+ We have confirmed that the tools you use in this tutorial work, and are easy to install, on Amazon Linux 2023, which we recommend for this tutorial.
+ Data operations between components in a VPC generally perform better than those over the internet.

**To create and configure an Amazon EC2 client to populate your source database**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. On the **Dashboard**, choose **Launch instance**.

1. On the **Launch an Instance** page, enter the following values:

   1. In the **Name and tags** section, enter **DMSClient** for **Name**.

   1. In the **Application and OS Images (Amazon Machine Image)** section, leave the settings as they are.

   1. In the **Instance Type** section, choose **t2.xlarge**.

   1. In the **Key pair (login)** section, choose **Create a new key pair**. 

   1. On the **Create key pair** page, enter the following:
      + **Key pair name**: **DMSKeyPair**
      + **Key pair type**: Leave as **RSA**.
      + **Private key file format**: Choose **pem** for OpenSSH on MacOS or Linux, or **ppk** for PuTTY on Windows.

      Save the key file when prompted.
**Note**  
You can also use an existing Amazon EC2 key pair rather than creating a new one.

   1. In the **Network Settings** section, choose **Edit**. Choose the following settings:
      + **VPC - *required***: Choose the VPC with the ID that you recorded for the **DMSVPC-vpc** VPC.
      + **Subnet**: Choose the first public subnet.
      + **Auto-assign public IP**: Choose **Enable**.

      Leave the rest of the settings as they are, and choose **Launch instance**.

## Populate your source database
<a name="CHAP_GettingStarted.Prerequisites.Populate"></a>

In this section, you find endpoints for your source and target databases for later use and use the following tools to populate the source database:
+ Git, to download the script that populates your source database.
+ MariaDB client, to run this script.

### Get endpoints
<a name="CHAP_GettingStarted.Prerequisites.Populate.Hosts"></a>

Find and note the endpoints of your RDS for MariaDB and RDS for PostgreSQL DB instances for later use.

**To find your DB instance endpoints**

1. Sign in to the AWS Management Console and open the Amazon RDS console at [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/).

1. On the navigation pane, choose **Databases**.

1. Choose the **dms-mariadb** database, and note the **Endpoint** value for the database.

1. Repeat the previous steps for the **dms-postgresql** database.

### Populate your source database
<a name="CHAP_GettingStarted.Prerequisites.Populate.Git"></a>

Next, connect to your client instance, install the necessary software, download AWS sample database scripts from Git, and run the scripts to populate your source database.

**To populate your source database**

1. Connect to the client instance using the host name and public key that you saved in previous steps. 

   For more information on connecting to an Amazon EC2 instance, see [Accessing Instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html) in the *Amazon EC2 User Guide*.
**Note**  
If you are using PuTTY, enable TCP keepalives on the **Connection** settings page so that your connection doesn't time out from inactivity.

1. Install Git, MariaDB, and PostgreSQL. Confirm installation as needed.

   ```
   $ sudo yum install git
   $ sudo dnf install mariadb105
   $ sudo dnf install postgresql15
   ```

1. Run the following command to download the database creation scripts from GitHub.

   ```
   git clone https://github.com/aws-samples/aws-database-migration-samples.git
   ```

1. Change to the `aws-database-migration-samples/mysql/sampledb/v1/` directory.

1. Run the following command. Provide the endpoint for your source RDS instance that you noted previously, for example `dms-mariadb.cdv5fbeyiy4e.us-east-1.rds.amazonaws.com`.

   ```
   mysql -h dms-mariadb.abcdefghij01.us-east-1.rds.amazonaws.com -P 3306 -u admin -p dms_sample < ~/aws-database-migration-samples/mysql/sampledb/v1/install-rds.sql
   ```

1. Let the database creation script run. The script takes up to 45 minutes to create the schema and populate the data. You can safely ignore errors and warnings that the script displays.

# Migrating your source schema to your target database using AWS SCT
<a name="CHAP_GettingStarted.SCT"></a>

We recommend using DMS Schema Conversion to convert your source database schemas. For more information, see [Getting started with DMS Schema Conversion](getting-started.md). If you prefer to use the legacy AWS Schema Conversion Tool, follow the steps below.

**To migrate your source schema to your target database with AWS SCT**

1. Install the AWS Schema Conversion Tool. For more information, see [ Installing, verifying, and updating the AWS SCT](https://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/CHAP_Installing.html#CHAP_Installing.Procedure) in the *AWS Schema Conversion Tool User Guide*. 

   When you download JDBC drivers for MySQL and PostgreSQL, note where you save the drivers, in case the tool prompts you for their locations.

1. Open the AWS Schema Conversion Tool. Choose **File**, then choose **New project**.

1. In the **New project** window, set the following values:
   + Set **Project name** to **DMSProject**.
   + Keep **Location** as it is to store your AWS SCT project in the default folder.

   Choose **OK**.

1. Choose **Add source** to add a source MySQL database to your project, then choose **MySQL**, and choose **Next**.

1. In the **Add source** page, set the following values:
   + **Connection name**: **source**
   + **Server name**: Enter the endpoint for the MySQL database that you noted previously.
   + **Server port**: **3306**
   + **User name**: **admin**
   + **Password**: **changeit**

1. Choose **Add target** to add a target Amazon RDS for PostgreSQL database to your project, then choose **Amazon RDS for PostgreSQL**. Choose **Next**.

1. In the **Add target** page, set the following values:
   + **Connection name**: **target**
   + **Server name**: Enter the endpoint for the PostgreSQL database that you noted previously.
   + **Server port**: **5432**
   + **Database**: Enter the name of your PostgreSQL database.
   + **User name**: **postgres**
   + **Password**: **changeit**

1. In the left pane, choose **dms\$1sample** under **Schemas**. In the right pane, choose your target Amazon RDS for PostgreSQL database. Choose **Create mapping**. You can add multiple mapping rules to a single AWS SCT project. For more information about mapping rules, see [Creating mapping rules](https://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/CHAP_Mapping.html). 

1. Choose **Main view**.

1. In the left pane, choose **dms\$1sample** under **Schemas**. Open the context (right-click) menu and choose **Convert schema**. Confirm the action.

   After the tool converts the schema, the **dms\$1sample** schema appears in the right pane.

1. In the right pane, under **Schemas**, open the context (right-click) menu for **dms\$1sample** and choose **Apply to database**. Confirm the action.

Verify that the schema migration completed. Perform the following steps.

**To check your schema migration**

1. Connect to your Amazon EC2 client.

1. Start the PSQL client with the following command. Specify your PostgreSQL database endpoint, and provide the database password when prompted.

   ```
   psql \
      --host=dms-postgresql.abcdefg12345.us-west-2.rds.amazonaws.com \
      --port=5432 \
      --username=postgres \
      --password \
      --dbname=dms_sample
   ```

1. Query one of the (empty) tables to verify that AWS SCT applied the schema correctly,

   ```
   dms_sample=> SELECT * from dms_sample.player;
    id | sport_team_id | last_name | first_name | full_name
   ----+---------------+-----------+------------+-----------
   (0 rows)
   ```

# Set up replication for AWS Database Migration Service
<a name="CHAP_GettingStarted.Replication"></a>

In this topic, you set up replication between the source and target databases.

## Step 1: Create a replication instance using the AWS DMS console
<a name="CHAP_GettingStarted.Replication.ReplicationInstance"></a>

To start work with AWS DMS, create a replication instance.

A *replication instance* performs the actual data migration between source and target endpoints. Your instance needs enough storage and processing power to perform the tasks that migrate data from your source database to your target database. How large this replication instance should be depends on the amount of data to migrate and the tasks your instance needs to do. For more information about replication instances, see [Working with an AWS DMS replication instance](CHAP_ReplicationInstance.md).

![\[Create replication instance\]](http://docs.aws.amazon.com/dms/latest/userguide/images/datarep-create-replication-30a.png)


**To create a replication instance using the console**

1. Sign in to the AWS Management Console and open the AWS DMS console at [https://console.aws.amazon.com/dms/v2/](https://console.aws.amazon.com/dms/v2/).

1. On the navigation pane, choose **Replication instances**, and then choose **Create replication instance**.

1. On the **Create replication instance** page, specify your replication instance configuration:

   1. For **Name**, enter **DMS-instance**. 

   1. For **Description**, enter a short description for your replication instance (optional).

   1. For **Instance class**, leave **dms.t3.medium** chosen.

      The instance needs enough storage, networking, and processing power for your migration. For more information about how to choose an instance class, see [Choosing the right AWS DMS replication instance for your migration](CHAP_ReplicationInstance.Types.md).

   1. For **Engine version**, accept the default.

   1. For **Multi AZ**, choose **Dev or test workload (Single-AZ)**.

   1. For **Allocated storage (GiB)**, accept the default of 50 GiB.

      In AWS DMS, storage is mostly used by log files and cached transactions. For cache transactions, storage is used only when the cached transactions need to be written to disk. As a result, AWS DMS doesn't use a significant amount of storage.

   1. For **Network type** choose **IPv4**.

   1. For **VPC**, choose **DMSVPC**.

   1. For **Replication subnet group**, leave the replication subnet group currently chosen.

   1. Clear **Publicly accessible**.

1. Choose the **Advanced security and network configuration** tab to set values for network and encryption settings if you need them: 

   1. For **Availability zone**, choose **us-west-2a**.

   1. For **VPC security group(s)**, choose the **Default** security group if it isn't already chosen.

   1. For **AWS KMS key**, leave **(Default) aws/dms** chosen.

1. Leave the settings on the **Maintenance** tab as they are. The default is a 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week.

1. Choose **Create**.

AWS DMS creates a replication instance to perform your migration.

## Step 2: Specify source and target endpoints
<a name="CHAP_GettingStarted.Replication.Endpoints"></a>

While your replication instance is being created, you can specify the source and target data store endpoints for the Amazon RDS databases you created previously. You create each endpoint separately.

![\[Create endpoint\]](http://docs.aws.amazon.com/dms/latest/userguide/images/datarep-create-endpoint-30a.png)


**To specify a source endpoint and database endpoint using the AWS DMS console**

1. On the console, choose **Endpoints** from the navigation pane and then choose **Create Endpoint**.

1. On the **Create endpoint** page, choose the **Source** endpoint type. Select the **Select RDS DB instance** box, and choose the **dms-mariadb** instance.

1. In the **Endpoint configuration** section, enter **dms-mysql-source** for **Endpoint identifier**.

1. For **Source engine**, leave **MySQL** chosen.

1. For **Access to endpoint database**, choose **Provide access information manually**. Verify that the **Port**, **Secure Socket Layer (SSL) mode**, **User name**, and **Password** are correct. 

1. Choose the **Test endpoint connection (optional)** tab. For **VPC**, choose **DMSVPC**.

1. For **Replication instance**, leave **dms-instance** chosen.

1. Choose **Run test**.

   After you choose **Run test**, AWS DMS creates the endpoint with the details that you provided and connects to it. If the connection fails, edit the endpoint definition and test the connection again. You can also delete the endpoint manually.

1. After you have a successful test, choose **Create endpoint**.

1. Specify a target database endpoint using the AWS DMS console. To do this, repeat the steps preceding, with the following settings:
   + **Endpoint type**: **Target endpoint**
   + **RDS Instance**: **dms-postgresql**
   + **Endpoint identifier**: **dms-postgresql-target**
   + **Target engine**: Leave **PostgreSQL** chosen.

When you're finished providing all information for your endpoints, AWS DMS creates your source and target endpoints for use during database migration. 

## Step 3: Create a task and migrate data
<a name="CHAP_GettingStarted.Replication.Tasks"></a>

In this step, you create a task to migrate data between the databases you created. 

![\[Create migration task\]](http://docs.aws.amazon.com/dms/latest/userguide/images/datarep-create-task-20a.png)


**To create a migration task and start your database migration**

1. In the console navigation pane, choose **Database migration tasks**, and then choose **Create task**. The **Create database migration task** page opens. 

1. In the **Task configuration** section, specify the following task options: 
   + **Task identifier**: Enter **dms-task**.
   + **Replication instance**: Choose your replication instance (**dms-instance-vpc-*<vpc id>***). 
   + **Source database endpoint**: Choose **dms-mysql-source**.
   + **Target database endpoint**: Choose **dms-postgresql-target**.
   + **Migration type**: Choose **Migrate existing data and replicate on-going changes**.

1. Choose the **Task settings** tab. Set the following settings:
   + **Target table preparation mode**: **Do nothing**
   + **Stop task after full load completes**: **Don't stop**

1. Choose the **Table mappings** tab, and expand **Selection rules**. Choose **Add new selection rule**. Set the following settings:
   + **Schema**: **Enter a schema**
   + **Schema name**: **dms\$1sample**

1. Choose the **Migration task startup configuration** tab. Select **Start with premigration assessments (recommended)** to run assessments before starting the task. Alternatively, you can choose **Start automatically on create** to begin migration immediately, or **Run assessments only** to evaluate without starting the task.  
![\[Create migration task\]](http://docs.aws.amazon.com/dms/latest/userguide/images/datarep-create-task-21.png)

1. Choose **Create task**.

AWS DMS then creates the migration task and starts it. The initial database replication takes about 10 minutes. Make sure to do the next step in the tutorial before AWS DMS finishes migrating the data.

## Step 4: Test replication
<a name="CHAP_GettingStarted.Replication.Monitoring"></a>

In this section, you insert data into the source database during and after initial replication, and query the target database for the inserted data.

**To test replication**

1. Make sure that your database migration task shows a status of **Running** but your initial database replication, started in the previous step, isn't complete.

1. Connect to your Amazon EC2 client, and start the MySQL client with the following command. Provide your MySQL database endpoint.

   ```
   mysql -h dms-mysql.abcdefg12345.us-west-2.rds.amazonaws.com -P 3306 -u admin -pchangeit dms_sample
   ```

1. Run the following command to insert a record into the source database.

   ```
   MySQL [dms_sample]> insert person (full_name, last_name, first_name) VALUES ('Test User1', 'User1', 'Test');
   Query OK, 1 row affected (0.00 sec)
   ```

1. Exit the MySQL client.

   ```
   MySQL [dms_sample]> exit
   Bye
   ```

1. Before replication completes, query the target database for the new record. 

   From the Amazon EC2 instance, connect to the target database using the following command, providing your target database endpoint.

   ```
   psql \
      --host=dms-postgresql.abcdefg12345.us-west-2.rds.amazonaws.com \
      --port=5432 \
      --username=postgres \
      --password \
      --dbname=dms_sample
   ```

   Provide the password (**changeit**) when prompted.

1. Before replication completes, query the target database for the new record. 

   ```
   dms_sample=> select * from dms_sample.person where first_name = 'Test';
    id | full_name | last_name | first_name
   ----+-----------+-----------+------------
   (0 rows)
   ```

1. While your migration task is running, you can monitor the progress of your database migration as it happens:
   + In the DMS console navigation pane, choose **Database migration tasks**.
   + Choose **dms-task**.
   + Choose **Table statistics**.

   For more information about monitoring, see [Monitoring AWS DMS tasks](CHAP_Monitoring.md).

1. After replication completes, query the target database again for the new record. AWS DMS migrates the new record after initial replication completes.

   ```
   dms_sample=> select * from dms_sample.person where first_name = 'Test';
      id    | full_name  | last_name | first_name
   ---------+------------+-----------+------------
    7077784 | Test User1 | User1     | Test
   (1 row)
   ```

1. Exit the psql client.

   ```
   dms_sample=> quit
   ```

1. Repeat step 1 to connect to the source database again.

1. Insert another record into the `person` table.

   ```
   MySQL [dms_sample]> insert person (full_name, last_name, first_name) VALUES ('Test User2', 'User2', 'Test');
   Query OK, 1 row affected (0.00 sec)
   ```

1. Repeat steps 3 and 4 to disconnect from the source database and connect to the target database.

1. Query the target database for the replicated data again.

   ```
   dms_sample=> select * from dms_sample.person where first_name = 'Test';
      id    | full_name  | last_name | first_name
   ---------+------------+-----------+------------
    7077784 | Test User1 | User1     | Test
    7077785 | Test User2 | User2     | Test
   (2 rows)
   ```

## Step 5: Clean up AWS DMS resources
<a name="CHAP_GettingStarted.Replication.Deleting"></a>

After you complete the getting started tutorial, you can delete the resources you created. You can use the AWS console to remove them. Make sure to delete the migration tasks before deleting the replication instance and endpoints.

**To delete a migration task using the console**

1. On the AWS DMS console navigation pane, choose **Database migration tasks**.

1. Choose **dms-task**.

1. Choose **Actions**, **Delete**. 

**To delete a replication instance using the console**

1. On the AWS DMS console navigation pane, choose **Replication instances**.

1. Choose **DMS-instance**.

1. Choose **Actions**, **Delete**. 

AWS DMS deletes the replication instance and removes it from the **Replication instances** page.

**To remove endpoints using the console**

1. On the AWS DMS console navigation pane, choose **Endpoints**.

1. Choose **dms-mysql-source**.

1. Choose **Actions**, **Delete**.

After you delete your AWS DMS resources, make sure also to delete the following resources. For help with deleting resources in other services, see each service's documentation.
+ Your RDS databases.
+ Your RDS database parameter groups.
+ Your RDS subnet groups.
+ Any Amazon CloudWatch logs that were created along with your databases and replication instance.
+ Security groups that were created for your Amazon VPC and Amazon EC2 client. Make sure to remove the inbound rule from **Default** for the **launch-wizard-1** security groups, which is necessary for you to be able delete them.
+ Your Amazon EC2 client.
+ Your Amazon VPC.
+ Your Amazon EC2 key pair for your Amazon EC2 client.