Delete an instance asynchronously

Delete an instance asynchronously.

Code sample

Python

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

from google.api_core.exceptions import NotFound

from google.cloud import bigtable_admin_v2

async with bigtable_admin_v2.BigtableInstanceAdminAsyncClient() as client:
    instance_path = client.instance_path(project_id, instance_id)

    print("\nDeleting instance")
    try:
        await client.delete_instance(name=instance_path)
        print(f"Deleted instance: {instance_id}")
    except NotFound:
        print(f"Instance {instance_id} does not exist.")

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.