DMS replication instance enables public access

Public access on a DMS replication instance can create unnecessary external communication paths. Establish private connectivity and plan instance replacement and task continuity before changing it.

Description

publicly_accessible controls the DMS replication instance’s public IP. Subnet routes, security groups and endpoint rules determine its connections. Access to the databases, migration settings and credentials is controlled separately.

Potential impact

An unnecessary public address and permissive network rules can create unwanted connections. Replacement can also interrupt replication if either endpoint is unreachable.

Remediation

  • If a public IP is unnecessary, set publicly_accessible = false. Check the provider reference, terraform plan and the deployed setting if the value was omitted. Limit security groups and destination allow-lists to the required addresses and ports. Use VPC, peering, VPN or Direct Connect paths as appropriate, with outbound connectivity for any internet destination.
  • Review terraform plan for the required instance replacement and any dependent changes. Check that identifiers will not conflict while both instances exist. Plan for task-movement requirements, downtime, resumption and recovery. Keep the old resources until you have tested both endpoints and verified replication and data consistency.

Examples

Define the referenced subnet group and IAM policy attachments. Substitute the security group ID and KMS key ARN, and use the same Region for the provider, subnets and key. Select an engine version and capacity appropriate for the workload.

Before

hcl
resource "aws_dms_replication_instance" "test" {
  allocated_storage            = 20
  apply_immediately            = true
  auto_minor_version_upgrade   = true
  kms_key_arn                  = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
  multi_az                     = false
  preferred_maintenance_window = "sun:10:30-sun:14:30"
  publicly_accessible          = true
  replication_instance_class   = "dms.t3.micro"
  replication_instance_id      = "test-dms-replication-instance-tf"
  replication_subnet_group_id  = aws_dms_replication_subnet_group.test-dms-replication-subnet-group-tf.id

  vpc_security_group_ids = [
    "sg-12345678",
  ]

  depends_on = [
    aws_iam_role_policy_attachment.dms-access-for-endpoint-AmazonDMSRedshiftS3Role,
    aws_iam_role_policy_attachment.dms-cloudwatch-logs-role-AmazonDMSCloudWatchLogsRole,
    aws_iam_role_policy_attachment.dms-vpc-role-AmazonDMSVPCManagementRole
  ]
}

After

hcl
resource "aws_dms_replication_instance" "test" {
  allocated_storage            = 20
  apply_immediately            = true
  auto_minor_version_upgrade   = true
  kms_key_arn                  = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
  multi_az                     = false
  preferred_maintenance_window = "sun:10:30-sun:14:30"
  publicly_accessible          = false
  replication_instance_class   = "dms.t3.micro"
  replication_instance_id      = "test-dms-replication-instance-tf"
  replication_subnet_group_id  = aws_dms_replication_subnet_group.test-dms-replication-subnet-group-tf.id

  vpc_security_group_ids = [
    "sg-12345678",
  ]

  depends_on = [
    aws_iam_role_policy_attachment.dms-access-for-endpoint-AmazonDMSRedshiftS3Role,
    aws_iam_role_policy_attachment.dms-cloudwatch-logs-role-AmazonDMSCloudWatchLogsRole,
    aws_iam_role_policy_attachment.dms-vpc-role-AmazonDMSVPCManagementRole
  ]
}

Explanation: Both configurations use the same replication-instance ID. Account for that name when planning the replacement and test how the new instance reaches each endpoint.

References