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

Last updated: 2022-12-02

I want to 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 (AZs) 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.
  • There are no DB instances launched in the subnet that you want to delete.

If you launch a DB instance with a subnet group containing two subnets in two AZs, then you can't delete any subnets from the subnet group. For more information, see Working with a DB Instance in a VPC.

If a Multi-AZ deployment has two or more subnets, then you can launch the instance in any subnets in the AZs.

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

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. These 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, then 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 AZ 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, choose the subnet that you want to delete, and then choose Remove.
  8. Choose Save.

Did this article help?


Do you need billing or technical support?