How do I change the VPC for an RDS DB instance?

Last updated: 2019-04-09

How can I move my Amazon Relational Database Service (Amazon RDS) DB instance from an existing virtual private cloud (VPC) to a new VPC?

Short Description

Before you move the RDS DB instance to a new network, configure the new VPC, including the security group inbound rules, the subnet group, and the route tables. When you change the VPC for a DB instance, the instance reboots when the instance moves from one network to another. Because the DB instance isn't accessible while the instance is being moved, change the VPC during a scheduled maintenance window.

You can't change the VPC for a DB instance if:

  • The DB instance is in multiple Availability Zones. Convert the DB instance to a single Availability Zone, and then convert it back to a Multi-AZ DB instance after moving to the new VPC. For more information about converting instances, see High Availability (Multi-AZ) for Amazon RDS.
    Note: You can't change a DB subnet group to a Multi-AZ configuration. By default, the Amazon Aurora storage is Multi-AZ—even for a single instance—so you can't modify the VPC for Amazon Aurora. To change the VPC for an Amazon Aurora instance, see How can I change the VPC of an Amazon Aurora for MySQL or PostgreSQL cluster?
  • The DB instance is a read replica or has read replicas. Remove the read replicas, and then add read replicas after the DB instance is moved to the new VPC.
  • The subnet group created in the target VPC must have subnets from the Availability Zone where source database is running. If the Availability Zones are different, the operation fails.

Resolution

  1. Open the Amazon RDS console, and then choose Subnet Groups from the left navigation pane.
  2. Choose Create DB Subnet Group.
  3. Enter the subnet name, description, and VPC ID, and then choose the subnets needed for the DB instance.
  4. Choose Create.
  5. Choose Databases from the left navigation pane.
  6. Select the DB instance, choose Instance Actions, and then choose Modify.
  7. Under Network & Security, select the Subnet Group associated with the new VPC, and then choose the appropriate Security Group for that VPC.
  8. Choose Apply Immediately, and then choose Continue.
    Note: If you don't choose Apply Immediately, the VPC is modified during the next maintenance window.
  9. Review the details on the Modify DB Instance page, and then choose Modify DB Instance.

This task can take several minutes to complete. You can confirm that the subnet is changed by selecting the instance and then navigating to the configuration details page, which shows that the subnet group is updated and the status is Complete. You can also open the RDS console and then choose Events in the left navigation pane to confirm that the process moved the DB instance to the target VPC.


Did this article help you?

Anything we could improve?


Need more help?