Subchapter 63.31
references/onboarding.mdMarkdown15 KBView on GitHub
This guide provides steps to help users get started with Aurora DSQL in their project. It sets up their DSQL cluster with IAM authentication and connects their database to their code by understanding the context within the codebase.
These guidelines apply when users say “Get started with DSQL” or similar phrases. The user’s codebase may be mature (with existing database connections) or have little to no code - the guidelines should apply to both cases.
Keep all responses succinct:
Examples:
TRIGGER PHRASE: When the user says “Get started with DSQL”, “Get started with Aurora DSQL”, or similar phrases, provide an interactive onboarding experience by following these steps:
Before starting: Let the user know they can pause and resume anytime by saying “Continue with DSQL setup” if they need to come back later.
RESUME TRIGGER: If the user says “Continue with DSQL setup” or similar, check what’s already configured (AWS credentials, clusters, AWS MCP Server installation if applicable, connection tested) and resume from where they left off. Ask them which step they’d like to continue from or analyze their setup to determine automatically.
Check AWS credentials:
aws sts get-caller-identityIf not configured:
Guide them through aws configure
MUST verify IAM permissions include dsql:CreateCluster, dsql:GetCluster, dsql:DbConnectAdmin
For initial setup, use a scoped inline policy with only the minimum permissions needed. dsql:CreateCluster and dsql:ListClusters cannot target a specific cluster ARN (the cluster does not yet exist, and ListClusters is a list operation), so they go in a separate statement with Resource: "*". Cluster-scoped actions stay on the specific ARN:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dsql:CreateCluster",
"dsql:ListClusters"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"dsql:GetCluster",
"dsql:DeleteCluster",
"dsql:DbConnectAdmin"
],
"Resource": "arn:aws:dsql:<region>:<account-id>:cluster/<cluster-id>"
}
]
}Replace <cluster-id> with the actual cluster ID returned from cluster creation. After Step 4, narrow the first statement further by adding an aws:RequestTag/<key> condition to dsql:CreateCluster (or remove dsql:CreateCluster entirely once the cluster exists). aws:RequestTag is required here because dsql:CreateCluster runs before any cluster (and any resource tag) exists. Revoke dsql:DbConnectAdmin after scoped database roles are established (Step 9).
Check PostgreSQL client:
psql --versionIf missing OR version <=14: DSQL requires SNI support from psql >=14.
macOS: brew install postgresql@17
Linux (Debian/Ubuntu): sudo apt-get install postgresql-client
Linux (RHEL/CentOS/Amazon Linux):
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql17Set region (uses AWS_REGION or REGION if set, defaults to us-east-1):
REGION=${AWS_REGION:-${REGION:-us-east-1}}
echo $REGIONList clusters in the region:
aws dsql list-clusters --region $REGIONIf they have NO clusters:
If they have ANY clusters:
Create cluster command (if needed):
aws dsql create-cluster --region $REGION --tags '{"Name":"my-dsql-cluster","created_by":"<model-id>"}'Wait for ACTIVE status (takes ~60 seconds):
aws dsql get-cluster --identifier CLUSTER_ID --region $REGIONConstruct cluster endpoint:
CLUSTER_ID="<selected-cluster-id>"
CLUSTER_ENDPOINT="${CLUSTER_ID}.dsql.${REGION}.on.aws"
echo $CLUSTER_ENDPOINTStore endpoint for their project environment:
.env file or environment configDSQL_ENDPOINT=<endpoint>AWS_REGION=$REGION.env first before modifyingecho "DSQL_ENDPOINT=$CLUSTER_ENDPOINT" >> .envWould the user like AWS knowledge tools (documentation search/read, AWS API access) wired into their coding assistant?
If so, install the AWS MCP Server (opens in a new tab) per the AWS docs. It provides:
aws___search_documentation / aws___read_documentation / aws___recommend — DSQL docs lookupaws___call_aws — authenticated AWS API calls (for dsql: actions like cluster management)aws___run_script — sandboxed Python with AWS API accessA custom DSQL-specific MCP is optional. If the user has one configured already, it can stay
alongside the AWS MCP Server. For ad-hoc DSQL queries, this skill PREFERS direct psql via
scripts/psql-connect.sh over MCP-mediated execution.
⚠️ Security Note: The admin connection (
generate-db-connect-admin-auth-token+adminuser) should only be used for the initial setup steps below (creating roles, granting permissions). Once scoped roles are established in Step 9, all subsequent operations should use the scoped role withgenerate-db-connect-auth-token. Consider revokingdsql:DbConnectAdminfrom the setup IAM role after scoped roles are in place.
Generate authentication token and connect:
export PGPASSWORD=$(aws dsql generate-db-connect-admin-auth-token \
--region $REGION \
--hostname $CLUSTER_ENDPOINT \
--expires-in 3600)
export PGSSLMODE=verify-full
export PGAPPNAME="<app-name>/<model-id>"
psql --quiet -h $CLUSTER_ENDPOINT -U admin -d postgresVerify with test query:
SELECT current_database(), version();If connection fails:
First, check if this is an empty/new project:
If empty or near-empty project:
If established project:
ALWAYS reference ./development-guide.md before making schema changes
Based on their language, install appropriate driver (some examples):
JavaScript/TypeScript:
npm install @aws/aurora-dsql-node-postgres-connector tsxPython:
pip install aurora-dsql-python-connector 'psycopg[binary]' psycopg-poolGo:
go get github.com/awslabs/aurora-dsql-connectors/go/pgxRust:
cargo add aurora-dsql-sqlx-connector --features pool,occ
cargo add sqlx tokio --features postgres,runtime-tokio-native-tls,fullFor implementation patterns, reference ./dsql-examples.md and ./language.md
Check for existing schema:
.sql files, migration folders, ORM schemas (Prisma, Drizzle, TypeORM)If existing schema found:
GENERATED AS IDENTITY with sequences, or UUID)./development-guide.md for full constraintsIf no schema found:
If creating example table:
Use scripts/psql-connect.sh --admin to execute:
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX ASYNC idx_users_email ON users(email);For custom schema:
./dsql-examples.md for patternsCREATE INDEX ASYNC for all indexesRecommend creating scoped roles before application development begins.
admin directly.”-- As admin
CREATE ROLE app_user WITH LOGIN;
AWS IAM GRANT app_user TO 'arn:aws:iam::<account-id>:role/<AppIAMRole>';
GRANT USAGE ON SCHEMA public TO app_user;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO app_user;CREATE SCHEMA users_schema;
GRANT USAGE ON SCHEMA users_schema TO app_user;
GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA users_schema TO app_user;
GRANT CREATE ON SCHEMA users_schema TO app_user;generate-db-connect-auth-token (not the admin variant)Let them know you’re ready to help with more:
“You’re all set! Here are some things I can help with - feel free to ask about any of these (or anything else):
./development-guide.md before schema operationsscripts/psql-connect.sh for DSQL queries; reach for the AWS MCP Server when AWS knowledge or dsql: API calls are neededALWAYS follow these rules:
CREATE INDEX ASYNC - synchronous index creation not supportedPGSSLMODE=verify-full or sslmode=verify-full (use require as a fallback only when the CA bundle is unavailable)Leverage Aurora DSQL capabilities:
For detailed patterns, see ./development-guide.md