postgresqlamazon-web-servicesamazon-rdsamazon-aurora

How can I connect to my aurora serverless v2 database instance?


I have deployed an aurora serverless v2 postgres database in aws, and have enabled an http endpoint and have enabled publicly_accessible = true in the instance settings in terraform. I have verified that I can write to the db from my local machine, but I wanted to inspect the tables and drop the alembic_versions tables manually if necessary in order to recreate things from scratch, and also to query the contents of the tables easily.

I have tried using the rds api via the aws cli, because I have previously managed this with aurora v1. I provide the instance identifier as the --database parameter, but I get an error message saying the database does not exist. When I provide the database_name from the rds_cluster declaration in terraform instead, I can't find my tables when I query. I have also tried the query editor in the aws console, and that's the same story.

Does anyone know how to do this easily when you have an aurora serverless db instance?


Solution

  • I provide the instance identifier as the --database parameter, but I get an error message saying the database does not exist

    The --database parameter is completely unrelated to the instance identifier. The --database parameter is not for specifying a database server instance. The --database parameter is for specifying which database inside PostgreSQL the query needs to run against. A single database server can have multiple databases in it.

    This is the database either created by you in PostgreSQL when you ran the command CREATE DATABASE <dbname> or when you first created the RDS or Aurora instance/cluster and specified a "database name" parameter. In Terraform that would be the database_name parameter on the aws_rds_cluster resource. For PostgreSQL, RDS does not force you to provide a database name so you may not have a database created on your server yet.