View a markdown version of this page

Cleaning up resources - Amazon Aurora

Cleaning up resources

To avoid charges, remove the test resources that you created in this tutorial. Remove the routing data first, then the member clusters, and then the database cluster group for Aurora.

If you added clusters that you already run, remove them from the tutorial group, but don't delete the clusters. On version 8.4.900, DB instances run only in clusters that belong to a group, so delete a member cluster's DB instances before you remove it. A removed cluster keeps its storage and backups but can't serve connections. To take an existing cluster out of a group that you keep using, see Removing a member cluster.

Removing the tutorial resources

If you enabled routing, first remove the routing data. A DELETE with no WHERE clause removes up to 1,000 data mappings from across the group, and skips mappings that scaleout tables use. Delete the tutorial row by name.

To remove the routing data
  1. At the routing endpoint, as the administrative router user, delete the database-level mapping row. An empty router_table_name selects only the database-level row.

    DELETE FROM dbclustergroup_sys.data_mappings WHERE (router_db_name, router_table_name) = ('tenant_0001', '');
  2. At the routing endpoint, drop the router user.

    DROP USER 'app_user'@'%';
  3. On each member cluster, through its own cluster endpoint, drop app_user.

    DROP USER 'app_user'@'%';
  4. On the first member cluster, through its own cluster endpoint, drop the tutorial database.

    DROP DATABASE tenant_0001;

Then remove the member clusters and delete the group. You can't delete a cluster while it's a member of a group, so remove it from the group first.

Console
To remove the member clusters (console)
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. Delete every DB instance of each member cluster. On the Databases page, select each instance, choose Actions, and then choose Delete. Wait until the cluster shows no DB instances before you continue.

  3. In the navigation pane, choose Database cluster groups, and then choose the group.

  4. On the Member clusters tab, select a member cluster.

  5. Choose Actions, and then choose Remove from group.

  6. Confirm that you want to remove the cluster.

  7. Repeat steps 4 through 6 for each remaining member cluster, one at a time.

For the checks to run before you remove a cluster from a group that you keep, see Removing a cluster from a group.

To delete the group (console)
  1. In the navigation pane, choose Database cluster groups, and then choose the group.

  2. If routing is enabled, choose Modify, clear Enable routing, choose Confirm, and then choose Save changes. The console doesn't delete a group that has routing enabled.

  3. Choose Actions, and then choose Delete cluster group.

  4. Enter the group identifier to confirm the deletion, and then choose Confirm.

  5. If you created clusters for the tutorial, delete them, as described in Deleting Aurora DB clusters and DB instances.

If deletion protection is on, or if you want to keep the group's automated backups, see Deleting a database cluster group for Aurora.

AWS CLI
To remove the member clusters and delete the group (AWS CLI)
  1. Delete every DB instance of each member cluster (aws rds delete-db-instance), and wait until describe-db-clusters shows no DBClusterMembers.

  2. With the AWS CLI, remove each member cluster, one at a time, with RemoveDBClusterFromDBClusterGroup (aws rds remove-db-cluster-from-db-cluster-group).

    aws rds remove-db-cluster-from-db-cluster-group --region REGION \ --db-cluster-group-identifier GROUP_IDENTIFIER --db-cluster-identifier CLUSTER_IDENTIFIER
  3. With the AWS CLI, delete the group with DeleteDBClusterGroup (aws rds delete-db-cluster-group).

    aws rds delete-db-cluster-group --region REGION --db-cluster-group-identifier GROUP_IDENTIFIER
  4. If you created clusters for the tutorial, delete them, as described in Deleting Aurora DB clusters and DB instances.

Amazon RDS API

Call RemoveDBClusterFromDBClusterGroup with DBClusterGroupIdentifier and DBClusterIdentifier for each member cluster, one at a time. Then call DeleteDBClusterGroup with DBClusterGroupIdentifier. To delete clusters that you created for the tutorial, call DeleteDBCluster.

A removal doesn't check or delete the data mappings that name the cluster, so delete them first, as in the routing data procedure. If the member cluster is stopped, a DELETE of its data mappings fails with error 3168 until you remove the member cluster, so remove it first, then delete its mappings. On version 8.4.900, a removed member cluster keeps its storage and backups but has no DB instances, so it can't serve connections. For the full steps and checks, see Adding and removing member clusters and Creating, modifying, and deleting a database cluster group for Aurora.

For the parameters of each call, see the Amazon RDS API Reference.

Next steps

Each of the following is a separate choice that you can make later. To run a group day to day, see Managing a database cluster group for Aurora, including the following topics:

To bring the clusters that you run today into a group, see Add member clusters. If your application already splits data across them, see Describing existing data partitions with data mappings and Sending traffic through the routing layer.

Placing and moving data when you use routing

If you use routing, you choose placement and movement for one database or table at a time, when you're ready:

Before you place two databases on different member clusters, find the statements that join or write both of them. Split those statements, or keep those databases in one collocation.