Are you encountering an error while attempting to create an instance in AWS Database Migration Service (DMS)? Don't fret; you're not alone. Recently, I stumbled upon an issue during DMS instance creation and delved into the solution to share my insights with you.
The Error:
You might come across an error message similar to this:
**Error**: creating DMS Replication Instance (my-replication-instance1): InvalidSubnet: No default subnet detected in VPC. Please contact AWS Support to recreate default Subnets
Understanding the Error:
This error crops up when DMS fails to identify a default subnet in the Virtual Private Cloud (VPC). By default, DMS attempts to utilize the default VPC subnet group. However, if the default VPC or its associated subnet group isn't available, the creation process hits a snag.
Root Cause:
The crux of the issue lies in the absence of a specified subnet group. Without explicit instructions, DMS defaults to the non-existent default VPC subnet group, resulting in the error.
Resolution:
The fix is straightforward. Create a DMS subnet group aligned with the custom subnets provisioned in your VPC. Then, when initiating the replication instance creation, ensure to specify this subnet group explicitly.
Implementation via AWS CDK:
Here's a step-by-step guide to achieving the resolution using AWS CDK:
Import Necessary Libraries:
import { DmsReplicationInstance } from "@cdktf/provider-aws/lib/dms-replication-instance";
import { DmsReplicationSubnetGroup } from "@cdktf/provider-aws/lib/dms-replication-subnet-group";
Define Constants:
const replicationSubnetGroup = new DmsReplicationSubnetGroup(
stacks.infra,
"MyReplicationSubnetGroup",
{
replicationSubnetGroupDescription: "MyReplicationSubnetGroup",
replicationSubnetGroupId: "my-replication-subnet-group1",
subnetIds: _app.privateSubnetIds,
}
);
Specify the Subnet:
replicationSubnetGroupId: replicationSubnetGroup.id
Additional Resources:
For further guidance, refer to the following documents:
[+] Creating a replication instance - https://docs.aws.amazon.com/dms/latest/userguide/CHAP_ReplicationInstance.Creating.html
[+] aws dms - create-replication-instance
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dms/create-replication-instance.html
Top comments (0)