Use the PostgreSQL interactive terminal (psql) to access Aurora DSQL
Use AWS CloudShell to access Aurora DSQL with the PostgreSQL interactive terminal (psql)
Use the following procedure to access Aurora DSQL with the PostgreSQL interactive terminal from AWS CloudShell. For more information, see What is AWS CloudShell.
To connect using AWS CloudShell
-
Sign in to the Aurora DSQL console
. -
Choose the cluster for which you would like to open in CloudShell. If you haven't yet created a cluster, follow the steps in Step 1: Create an Aurora DSQL single-Region cluster or Create a multi-Region cluster.
-
Choose Connect with Query Editor and then choose Connect with CloudShell.
-
Choose whether you want to connect as an admin or with a custom database role.
-
Choose Launch in CloudShell and choose Run in the following CloudShell dialog.
Use the local CLI to access Aurora DSQL with the PostgreSQL interactive terminal (psql)
Use psql, a terminal-based front-end to PostgreSQL utility, to interactively enter in queries, issue them to PostgreSQL, and view the query results.
Note
To improve query response times, use the PostgreSQL version 17 client. If you use the CLI in a different environment, make sure you manually set up Python version 3.8+ and psql version 14+.
Download your operating system's installer from the PostgreSQL Downloadspsql, see PostgreSQL Client Applications
If you already have the AWS CLI installed, use the following example to connect to your cluster.
# Aurora DSQL requires a valid IAM token as the password when connecting. # Aurora DSQL provides tools for this and here we're using Python. export PGPASSWORD=$(aws dsql generate-db-connect-admin-auth-token \ --regionus-east-1\ --expires-in 3600 \ --hostnameyour_cluster_endpoint) # Aurora DSQL requires SSL and will reject your connection without it. export PGSSLMODE=require # Connect with psql, which automatically uses the values set in PGPASSWORD and PGSSLMODE. # Quiet mode suppresses unnecessary warnings and chatty responses but still outputs errors. psql --quiet \ --username admin \ --dbname postgres \ --hostyour_cluster_endpoint