How can I delete a subnet that is part of an Amazon RDS DB subnet group?

Last updated: 2020-06-10

How can I delete a subnet that is in an Amazon Relational Database Service (Amazon RDS) DB subnet group?

Short Description

To launch an Amazon RDS DB instance, an RDS DB subnet group must contain at least two subnets. These subnets must be in different Availability Zones in the same AWS Region. You can remove or delete a subnet from the DB subnet group only if there are no DB instances associated with the subnet group and launched in the subnet that you're trying to delete. If you launch a DB instance with a DB subnet group that contains two subnets in two Availability Zones, then you can't delete any subnet from the DB subnet group. For more information, see Working with a DB Instance in a VPC.

If you have a Multi-AZ deployment that has two or more subnets in a subnet group, then you can launch the DB instance in any of the subnets of the two Availability Zones.

If you have a Single-AZ deployment that has two or more subnets in the subnet group, then you can specify the Availability Zone when you create a DB instance. If you didn't specify the Availability Zone when you created the DB instance, then the DB instance is launched in any of the subnets of the two Availability Zones.

Resolution

To delete a subnet from a DB subnet group, isolate the subnet by moving the DB instance to another subnet. Then, remove the subnet from the DB subnet group. The following steps are applicable for Amazon RDS for Oracle, PostgreSQL, MySQL, MariaDB, or SQL Server.

Note: This resolution doesn't apply to Amazon Aurora, because Aurora uses replicas as failover targets. If an Aurora primary DB instance fails, the replica is promoted to the primary. This action is unlike most Multi-AZ deployments where there is a secondary DB instance in another Availability Zone.

Delete a subnet from a Single-AZ Amazon RDS DB instance

  1. Modify the DB Instance to be a Multi-AZ deployment. This creates a standby for the DB instance in a different Availability Zone that uses a different subnet.
    Note:
    If you already have a Multi-AZ deployment, skip to step 2.
  2. Reboot the DB instance with failover. This promotes the standby to the primary DB instance.
  3. Modify the DB instance back to a Single-AZ DB instance.
    Note:
    After you do this, the Single-AZ DB instance is no longer in the subnet that you want to delete.
  4. Open the Amazon RDS console, and then choose Subnet groups from the navigation pane.
  5. Choose the subnet group that the DB instance is associated with.
  6. Choose Edit.
  7. From Add subnets, select the subnet you want to delete, and then choose Remove.
  8. Choose Save.

Did this article help you?

Anything we could improve?


Need more help?