Terraform module for AWS DMS
the module create a target RDS Instance and if set also the replicas for the master instance.
Its also create a dms instance and endpoints for source and target RDS Instance. And a migration
task that not startet automaticly.
module "dms" {
count = var.enable_dms_replica ? 1 : 0
source = "../../modules/dms"
depends_on = [aws_db_instance.master, random_string.database_pass]
dms_instance_name = var.override_db_master_name != "" ? var.override_db_master_name : "${local.basename}"
source_address = aws_db_instance.master.address
source_subnet_ids = data.terraform_remote_state.db-vpc.outputs.private_subnets
source_vpc_security_group_ids = [aws_security_group.sg-db.id]
source_database_name = aws_db_instance.master.db_name
source_engine = var.engine
source_password = random_string.database_pass.result
source_username = var.username
source_port = var.port
source_instance_subnet_group_name = aws_db_subnet_group.default.name
dms_replication_instance_kms_key_arn = data.aws_kms_key.dms.arn
target_engine = var.engine
target_db_multi_az = var.db_multi_az
target_allocated_storage = var.target_allocated_storage != "" ? var.target_allocated_storage : var.allocated_storage
target_instance_name = var.target_instance_name
target_instance_type = var.target_instance_type
target_instance_engine_version = var.target_instance_engine_version
target_instance_parameter_group_name = var.target_instance_parameter_group_name
target_replica_count = var.replica_count
target_storage_encrypted = var.target_storage_encrypted
target_instance_kms_key_id = var.target_storage_encrypted ? data.aws_kms_key.rds.arn : null
}
- Set the rds.logical_replication parameter in your DB CLUSTER parameter group to 1
- Set wal_sender_timeout parameter to 0 in your DB CLUSTER parameter group
- reboot the source RDS Instance
- use AWS Systems Manager for schedule reboot.
- see https://aws.amazon.com/de/blogs/database/schedule-amazon-rds-stop-and-start-using-aws-systems-manager/
- start manually the migration task
- take care of hibernate sequence
- AWS DMS doesn't migrate your secondary indexes, sequences, default values, stored procedures, triggers, synonyms, views, and other schema objects that aren't specifically related to data migration.
- switch the application to the target RDS Instance
- Stop the migration task
- Remove the target Instance and Replicas from terraform state before removing all resources.
terragrunt state rm "module.dms[0].aws_db_instance.target_master_instance"
No requirements.
Name | Version |
---|---|
aws | n/a |
No modules.
Name | Description | Type | Default | Required |
---|---|---|---|---|
certificate_arn | (Optional, Default: empty string) ARN for the certificate. | string |
"" |
no |
dms_availability_zone | n/a | string |
"eu-central-1a" |
no |
dms_instance_class | n/a | string |
"dms.t3.micro" |
no |
dms_instance_name | n/a | string |
n/a | yes |
dms_replication_instance_kms_key_arn | n/a | string |
null |
no |
dms_replication_instance_multi_az | n/a | bool |
false |
no |
engine_version | n/a | string |
"3.4.7" |
no |
extra_connection_attributes | (Optional) Additional attributes associated with the connection. For available attributes see Using Extra Connection Attributes with AWS Database Migration Service. | string |
"" |
no |
kms_key_arn | n/a | string |
null |
no |
source_address | endpoint address of source | string |
n/a | yes |
source_database_name | Required) Database endpoint identifier. Identifiers must contain from 1 to 255 alphanumeric characters or hyphens, begin with a letter, contain only ASCII letters, digits, and hyphens, not end with a hyphen, and not contain two consecutive hyphens. | string |
"source" |
no |
source_engine | (Required) Type of engine for the source endpoint. Valid values are aurora, aurora-postgresql, azuredb, db2, docdb, dynamodb, elasticsearch, kafka, kinesis, mariadb, mongodb, mysql, opensearch, oracle, postgres, redshift, s3, sqlserver, sybase. Please note that some of engine names are available only for target endpoint type (e.g. redshift). | string |
n/a | yes |
source_instance_subnet_group_name | n/a | string |
n/a | yes |
source_password | (Optional) Password to be used to login to the endpoint database. | string |
"test" |
no |
source_port | n/a | number |
5432 |
no |
source_subnet_ids | n/a | list(string) |
[] |
no |
source_username | (Optional) User name to be used to login to the endpoint database. | string |
"test" |
no |
source_vpc_security_group_ids | n/a | list(string) |
[] |
no |
target_allocated_storage | The acclocated storage of the target database | number |
20 |
no |
target_availability_zones | AZ for the replicas | list(string) |
[ |
no |
target_db_multi_az | (Optional) Specifies if the target RDS instance is multi-AZ | bool |
false |
no |
target_engine | (Required) Type of engine for the target endpoint. Valid values are aurora, aurora-postgresql, azuredb, db2, docdb, dynamodb, elasticsearch, kafka, kinesis, mariadb, mongodb, mysql, opensearch, oracle, postgres, redshift, s3, sqlserver, sybase. Please note that some of engine names are available only for target endpoint type (e.g. redshift). | string |
n/a | yes |
target_instance_engine_version | the engine version of the target db | string |
"13.4" |
no |
target_instance_kms_key_id | n/a | string |
null |
no |
target_instance_name | Name of the target replica | string |
"test" |
no |
target_instance_parameter_group_name | n/a | string |
n/a | yes |
target_instance_type | instance type of the target instance | string |
"db.t3.micro" |
no |
target_replica_count | Amount of the target read replicas | number |
0 |
no |
target_storage_encrypted | (Optional) Specifies whether the DB instance is encrypted. The default is true if not specified. | bool |
true |
no |
target_storage_type | n/a | string |
"gp2" |
no |
upgrade_apply_immediately | (Optional) Specifies whether any database modifications are applied immediately, or during the next maintenance window. Default is false. See Amazon RDS Documentation for more information. | bool |
false |
no |
No outputs.