SourceFuse AWS Reference Architecture (ARC) Terraform module for creating Database Migration Service.
AWS DMS facilitates seamless, secure database migrations to AWS, enabling both homogeneous and heterogeneous data transfers with minimal downtime. DMS supports continuous data replication through Change Data Capture (CDC) and integrates with a broad range of source and target databases, providing a robust, scalable solution for reliable data migration.
For more information about this repository and its usage, please see Terraform AWS ARC CloudFront Usage Guide.
To see a DMS example, check out the main.tf file in the example folder.
module "aws_dms" {
source = "../modules/dms"
# Subnet
subnet_group_id = "dms-poc-public-subnet-group"
subnet_group_description = "Subnet for DMS POC"
subnet_group_subnet_ids = ["subnet-1", "subnet-2"] #List of Subnet IDs
# Instance
instance_allocated_storage = 5
instance_apply_immediately = true
instance_network_type = "IPV4"
instance_class = "dms.t2.micro"
instance_id = "DMS-POC"
instance_subnet_group_id = "dms-poc-public-subnet-group"
instance_publicly_accessible = true
instance_vpc_security_group_ids = ["<sg-id>"] #Security Group ID
endpoints = {
db1 = {
endpoint_id = "dms-poc-endpoint-1"
endpoint_type = "source"
engine_name = "postgres"
database_name = "poc"
secrets_manager_arn = "<secret-arn>" #Source endpoint secret arn
ssl_mode = "require"
postgres_settings = {
execute_timeout = 60
}
}
db2 = {
endpoint_id = "dms-poc-endpoint-2"
endpoint_type = "target"
engine_name = "postgres"
database_name = "poc_target"
secrets_manager_arn = "<secret-arn>" #Target endpoint secret arn
ssl_mode = "require"
}
}
replication_tasks = {
task1 = {
replication_task_id = "replication-task-1"
migration_type = "full-load" # Full load
source_endpoint_key = "db1" # References key in endpoints map
target_endpoint_key = "db2" # References key in endpoints map
table_mappings = "{\"rules\":[{\"rule-type\":\"selection\",\"rule-id\":\"1\",\"rule-name\":\"1\",\"object-locator\":{\"schema-name\":\"public\",\"table-name\":\"%\"},\"rule-action\":\"include\"}]}"
}
}
}
Name | Version |
---|---|
terraform | >= 1.4, < 2.0.0 |
aws | >= 4.0, < 6.0 |
No providers.
Name | Source | Version |
---|---|---|
aws_dms | ./modules/dms | n/a |
No resources.
Name | Description | Type | Default | Required |
---|---|---|---|---|
create_subnet_group | Determines whether the replication subnet group will be created | bool |
true |
no |
endpoints | Map of endpoints used in the system | map(object({ |
n/a | yes |
instance_allocated_storage | The amount of storage (in gigabytes) to be initially allocated for the replication instance. Min: 5, Max: 6144, Default: 50 | number |
null |
no |
instance_allow_major_version_upgrade | Indicates that major version upgrades are allowed | bool |
true |
no |
instance_apply_immediately | Indicates whether the changes should be applied immediately or during the next maintenance window | bool |
null |
no |
instance_auto_minor_version_upgrade | Indicates that minor engine upgrades will be applied automatically to the replication instance during the maintenance window | bool |
true |
no |
instance_availability_zone | The EC2 Availability Zone that the replication instance will be created in | string |
null |
no |
instance_class | The compute and memory capacity of the replication instance as specified by the replication instance class | string |
"dms.t2.micro" |
no |
instance_engine_version | The engine version number of the replication instance | string |
null |
no |
instance_id | The replication instance identifier. This parameter is stored as a lowercase string | string |
"dms-instance" |
no |
instance_kms_key_arn | The Amazon Resource Name (ARN) for the KMS key that will be used to encrypt the connection parameters | string |
null |
no |
instance_multi_az | Specifies if the replication instance is a multi-az deployment. You cannot set the availability_zone parameter if the multi_az parameter is set to true |
bool |
null |
no |
instance_network_type | The type of IP address protocol used by a replication instance. Valid values: IPV4, DUAL | string |
null |
no |
instance_preferred_maintenance_window | The weekly time range during which system maintenance can occur, in Universal Coordinated Time (UTC) | string |
null |
no |
instance_publicly_accessible | Specifies the accessibility options for the replication instance | bool |
null |
no |
instance_subnet_group_id | An existing subnet group to associate with the replication instance | string |
null |
no |
instance_vpc_security_group_ids | A list of VPC security group IDs to be used with the replication instance | list(string) |
null |
no |
replication_tasks | n/a | map(object({ |
{} |
no |
replication_tasks_serverless | Map of serverless replication tasks | map(object({ |
n/a | yes |
s3_endpoints | n/a | map(object({ |
n/a | yes |
subnet_group_description | The description for the subnet group | string |
"DMS Replication subnet group" |
no |
subnet_group_id | The name for the replication subnet group. Stored as a lowercase string, must contain no more than 255 alphanumeric characters, periods, spaces, underscores, or hyphens | string |
"DMS_replication_subnet_group" |
no |
subnet_group_subnet_ids | A list of the EC2 subnet IDs for the subnet group | list(string) |
[] |
no |
subnet_group_tags | A map of additional tags to apply to the replication subnet group | map(string) |
{} |
no |
Name | Description |
---|---|
certificates | A map of maps containing the certificates created and their full output of attributes and values |
dms_access_for_endpoint_iam_role_arn | ARN specifying the role |
dms_access_for_endpoint_iam_role_id | Name of the IAM role |
dms_access_for_endpoint_iam_role_unique_id | Stable and unique string identifying the role |
endpoints | A map of maps containing the endpoints created and their full output of attributes and values |
event_subscriptions | A map of maps containing the event subscriptions created and their full output of attributes and values |
replication_instance_arn | The Amazon Resource Name (ARN) of the replication instance |
replication_instance_tags_all | A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block |
replication_subnet_group_id | The ID of the subnet group |
replication_tasks | A map of maps containing the replication tasks created and their full output of attributes and values |
s3_endpoints | A map of maps containing the S3 endpoints created and their full output of attributes and values |
serverless_replication_tasks | A map of maps containing the serverless replication tasks (replication_config) created and their full output of attributes and values |
while Contributing or doing git commit please specify the breaking change in your commit message whether its major,minor or patch
For Example
git commit -m "your commit message #major"
By specifying this , it will bump the version and if you don't specify this in your commit message then by default it will consider patch and will bump that accordingly
- Configure pre-commit hooks
pre-commit install
- Tests are available in
test
directory - Configure the dependencies
cd test/ go mod init github.com/sourcefuse/terraform-aws-refarch-vpn go get github.com/gruntwork-io/terratest/modules/terraform
- Now execute the test
go test -timeout 30m
This project is authored by:
- SourceFuse