How to Change AWS RDS Instance Class using AWS CLI

It is easy to modify AWS RDS instance class using AWS console but in this post we will discuss about changing instance type using AWS CLI. It is always recommended to test Instance class upgrade on test instance before changing into production instance so that you can compare performance of both the instance type.

Please note that Upgrading RDS instance class will require a downtime of few minutes as the instance will move to a different host and the outage involved even if RDS instance is configured with Multi-AZ.

Must Read:
Find & Kill Blocking Sessions in RDS Oracle.
How to Recover deleted Aurora PostgreSQL Instance
Increase Amazon RDS Storage using Command Line – CLI

For Multi-AZ instances, the downtime is experienced only during the failover process as the change happens on the standby instance first and then the Primary instance is upgraded to the new Instance class with failover. Failover time is usually between 60-120 seconds, but can be affected by the database activity and other conditions at the time the primary DB instance became unavailable. As such, there is less downtime for changing the instance class of an instance that is Multi-AZ.

Sometimes you need to leverage AWS CLI command especially in depreciated version of RDS database engine like Oracle 12c or older version of PostgreSQL to change the instance class.

Before changing the instance class you can check both of the official document for the supported instance class for your DB engine here – 1. Supported instance class for your DB Engine.
2. Amazon RDS Instance Type Features.

Supported instance class example as per above document.

The below command lists the DB instance classes that are supported by a specific DB engine version in an AWS Region.
aws rds describe-orderable-db-instance-options --engine engine --engine-version version --query "*[].{DBInstanceClass:DBInstanceClass,StorageType:StorageType}|[?StorageType=='gp2']|[].{DBInstanceClass:DBInstanceClass}" --output text --region region

For example, the below command can be used to list the supported DB instance classes for version 13.6 of the RDS for PostgreSQL DB engine in US East region

aws rds describe-orderable-db-instance-options --engine postgres --engine-version 13.6 --query "*[].{DBInstanceClass:DBInstanceClass,StorageType:StorageType}|[?StorageType=='gp2']|[].{DBInstanceClass:DBInstanceClass}" --region us-east-1

Modifying Instance Class Command

To apply the changes immediately, you can use –apply-immediately parameter in CLI. If you don’t want to apply immediately then changes are put into the pending modification queue and will be applied during next maintenance window.

Sample command:
---------------------------
aws rds modify-db-instance --db-instance-identifier yourdbinstance --db-instance-class newinstanceclass --apply-immediately

Example:
-------------
aws rds modify-db-instance --db-instance-identifier orahow-prod --db-instance-class db.r5.2xlarge --apply-immediately

Modify Instance Class using AWS Console

You can also use AWS Console to modify the changes using GUI as mentioned – here.