DMS
π§ What is AWS DMS?¶
AWS Database Migration Service (DMS) helps you migrate databases from on-premises, cloud, or hybrid environments to AWS, between AWS services, or even from AWS to other clouds.
β It supports both homogeneous (e.g., MySQL to MySQL) and heterogeneous (e.g., Oracle to Aurora) migrations with near-zero downtime.
π Common Use Cases¶
| Use Case | Example |
|---|---|
| Cloud adoption | Migrate Oracle from on-prem to Amazon RDS |
| Cross-engine migration | Migrate SQL Server to Aurora PostgreSQL |
| Continuous replication | Sync data from on-prem to AWS in real-time |
| Analytics | Migrate transactional DB to Amazon Redshift |
| Disaster recovery | Maintain DR copy in another region |
π DMS Supports¶
| Source DBs | Target DBs |
|---|---|
| MySQL, PostgreSQL | RDS (Aurora, MySQL, PostgreSQL, etc.) |
| Oracle, SQL Server | Amazon S3, Redshift, DynamoDB |
| MariaDB, MongoDB | Kinesis, OpenSearch, DocumentDB |
| SAP ASE, IBM DB2, etc. | Snowflake (via Kinesis or S3) |
βοΈ How DMS Works¶
Basic Components:¶
-
Replication Instance
β EC2-based instance that runs the migration -
Source Endpoint
β Connection configuration to your source database -
Target Endpoint
β Connection configuration to your target database -
Migration Task
β Defines what to move, how, and with what rules
π Migration Modes¶
| Mode | Description |
|---|---|
| Full Load | One-time copy of existing data |
| CDC (Change Data Capture) | Replicate ongoing changes |
| Full Load + CDC | Initial data load + continuous sync |
π CDC uses the source DB's transaction logs to replicate changes.
π DMS Migration Flow¶
π§ͺ Example Terraform Snippet for DMS¶
resource "aws_dms_replication_instance" "example" {
replication_instance_id = "example-dms-instance"
replication_instance_class = "dms.t3.micro"
allocated_storage = 50
}
resource "aws_dms_endpoint" "source" {
endpoint_id = "source-endpoint"
endpoint_type = "source"
engine_name = "mysql"
username = "admin"
password = "password"
server_name = "source-db.mycompany.com"
port = 3306
}
resource "aws_dms_endpoint" "target" {
endpoint_id = "target-endpoint"
endpoint_type = "target"
engine_name = "aurora"
username = "admin"
password = "password"
server_name = "aurora-cluster.endpoint.rds.amazonaws.com"
port = 3306
}
resource "aws_dms_replication_task" "task" {
replication_task_id = "my-task"
replication_instance_arn = aws_dms_replication_instance.example.replication_instance_arn
source_endpoint_arn = aws_dms_endpoint.source.endpoint_arn
target_endpoint_arn = aws_dms_endpoint.target.endpoint_arn
migration_type = "full-load-and-cdc"
table_mappings = <<EOF
{
"rules": [
{
"rule-type": "selection",
"rule-id": "1",
"rule-name": "1",
"object-locator": {
"schema-name": "%",
"table-name": "%"
},
"rule-action": "include"
}
]
}
EOF
}
π§Ύ Pricing (2024)¶
| Resource | Cost |
|---|---|
| Replication instance | Starts at ~$0.018/hr (dms.t3.micro) |
| Data transfer | Free between AWS services in same region |
| Storage (logs/checkpoints) | Based on allocated volume |
| Free tier | 750 hours/month for 2 months (for t3.micro) |
π Security¶
| Feature | Supported |
|---|---|
| IAM Role-based access | β Yes |
| KMS Encryption | β Yes (at rest) |
| SSL for DB Connections | β Yes |
| VPC/Private Subnet | β Yes (best practice) |
| CloudWatch & SNS | β Logs + alerts |
π οΈ Best Practices¶
-
Place replication instance in same region and subnet as target
-
Enable multi-AZ for replication if needed
-
Use parameter groups to adjust retry/timeouts
-
Pre-create target schema (DMS wonβt create them in all engines)
-
Monitor task health using CloudWatch metrics and logs
π¨ Limitations¶
| Area | Details |
|---|---|
| Schema conversion | Not automatic β Use AWS SCT (Schema Conversion Tool) |
| Triggers, SPs | Not migrated; only data + indexes |
| Data types | Some conversions require mapping (e.g., BLOB to JSON) |
| CDC dependencies | CDC needs binary logs (e.g., binlog for MySQL) |
β TL;DR Summary¶
| Feature | AWS DMS |
|---|---|
| Migration types | Full Load, CDC, or both |
| Source/Target support | SQL, NoSQL, S3, Redshift, etc. |
| Real-time replication | β Yes (CDC) |
| Fully managed | β Yes |
| Terraform support | β Yes (with full component coverage) |
| Free tier | β 2 months (750 hours on t3.micro) |
| Schema migration | β Use AWS SCT separately |