How to move an Amazon RDS DB instance from an Amazon Virtual Private Cloud (Amazon VPC) to a new VPC
Tags: rds, vpc, securitygroups, subnets
Published: 2024-03-09 23:12:24

In this article, I am going to show you how to migrate an Amazon Relational Database Service (Amazon RDS) DB instance from one virtual private cloud (VPC) to another in the same AWS account. This is useful especially when you want to place your application stack and database in different VPCs for security reasons.

But this sort of approach has few limitations. 

- When you move the RDS DB instance to a new network and configure the new VPC, the DB instance reboots. So, change the VPC during a planned change window that is outside the RDS weekly maintenance window.

- The DB instance you’re migrating must be a single instance with no standby. It must not be a member of a cluster.

- Amazon RDS must not be in multiple Availability Zones. Convert the DB instance to a single AZ, and then convert it back to a Multi-AZ DB instance after moving to the new VPC.

- Amazon RDS must not have any 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 the source database is running. If the AZs are different, then the operation fails.

_**Let’s get started!**_

 
Please visit my **[GitHub Repository for RDS articles](https://github.com/awsmine/RDS_projects)** and **[GitHub Repository for VPC articles](https://github.com/awsmine/VPC_Projects)** on various topics being updated on constant basis.



# Objectives:

**1.** Create RDS Database Instance

**2.** Create a new VPC, Subnets, Route Tables, VPC Security Group

**3.** Create a new DB subnet group

**4.** Modify the Amazon RDS DB instance to use the new DB subnet group


# Pre-requisites:
- AWS user account with admin access, not a root account.
- an IAM role with permissions required for the VPC, subnets, and Amazon RDS console


# Resources Used:
**[Amazon RDS documentation](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html)**
**[AWS IAM Documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html)**
**[Amazon VPC documentation](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html)**

# Steps for implementation to this project:

## 1. Create RDS Database Instance

**1**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/27dpcv41ryc162ge34lq.png)
**2**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ma3xoedcs7vj6jxgh2tt.png)
**3**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y6jhf7tpy8uz74vq6k1e.png)
**4**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/asdgwly4deggdbdn5mry.png)
**5**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u6r07vd8sjc730phef56.png)
**6**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4iu0pz4l6saogusxm9i5.png)
**7**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ccv6bidsmtmtajixb94d.png)
**8**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vui9qaqqc85q0kepxery.png)
**9**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xps2svz48ne0y2oakju3.png)
**10**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qp2c1nw8kgerpepaj049.png)
**11**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/78vmu826nzc74bzn5lpy.png)
**12**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qv8r1qaeyatnnz5b53fg.png)
**13**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jzwqmsr0qyzbeezg3s3.png)
**14**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4le3zxmva2h2h8gl7rq.png)

**15**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f62fy8w80baas74vp14o.png)


**16**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/257nu8q7zazk2zxp0dhh.png)

**17**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pf8zc676zmy9shzo61zk.png)


## 2. Create a new VPC, Subnets, Route Tables, VPC Security Group
#### Create a new VPC
**1**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nkxrj8h14333px8sm71z.png)
**2**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z94y7ockon29u5z559el.png)
**3**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eq230fuuju3loz3f2rcg.png)

#### Create new Subnets
**1**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xtz5lx2ejve4hfkg4owt.png)
**2**



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gc68jleb0uhbjf94l2u6.png)


**3**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ikws35if1dhwf6tffxvy.png)


- Create subnet


#### Create a new Route Table
**1**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/871x1gsxn8lkty2k891n.png)

**2**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pt05so4c5nd2em5t3d4.png)
**3**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yl8ehm0apn8i9gcl3uvg.png)
**4**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xngyorvp6rvoygrya0zn.png)


#### Create a new VPC Security Group
**1**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/69g0x9uzcmiyrf22bs4z.png)
**2**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ylpq92u093z9xtabdpon.png)
**3**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ykua0z7vs6eehhttz04.png)
- Create security group



## 3. Create a new DB subnet group.

**1**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w78ewhuieap92c1l80kk.png)
**2**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pqb3mdipv8wyqwql1at.png)
- Create


## 4. Modify the Amazon RDS DB instance to use the new DB subnet group
**1**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zwwhwwhn5he7o1uaozxa.png)

**2**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/354ozcsyapexwjn49tw4.png)
**3**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l03jxq4nqdd102jtm6rs.png)
**4**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rrn5yu29aubg8a9b1sgh.png)
**5**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0u50bqf7p95ka801fp9h.png)
**6**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5awt860mcxenf6tz5rc.png)
**7**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3syj8y9cb53tvs6qt3p.png)
**8**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7re3zlnux3yayktg9zzv.png)
**9**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axpa8imww5gvuwq1w2n3.png)
**10**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/led16jn1fc3wcd9ggtzo.png)

**11**
- Continue
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x677cjc9snm740bjfo9u.png)
**12**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k1w3rknmvah4ibrsioj9.png)
**13**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9mii75yan15gh8pfbxm.png)

**14**

- When the migration to the target VPC is complete, the target VPC's default security group is assigned to the Amazon RDS DB instance. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fs4dcoty887o2a2no7p7.png)
**15**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wqp55635wx2xkzlvya6.png)


**16**
- choose Events in the left navigation pane. 
- Confirm that the process moved the DB instance to the target VPC
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4km9w1fccbvtfqtx13o.png)
**17**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bzapvg6ryv671u3mfiq8.png)


# Cleanup
- delete RDS instance
- delete VPC and its components

# What we have done so far
I have successfully moved an Amazon RDS DB instance to a new VPC, by first changing its subnet group.