Remote clusters
Pre-requisites
- VPN connected
- AWS SSO authenticated (see AWS setup & CLI auth)
Starting the tunnel
The tunnel command opens an SSH tunnel to the Aurora cluster and forwards it to localhost:5432.
luna -e <env> aurora tunnel startValid environments are polaris, pulsar, staging, and production.
The tunnel script retrieves the SSH key automatically from Parameter Store at /luna/aurora-ssh-tunnel/luna-bastion on first use and saves it to ~/.ssh/luna-bastion-non-prod.pem (or luna-bastion-prod.pem for production). The key file is reused on subsequent runs.
Stop it with:
luna -e <env> aurora tunnel stopCheck tunnel status with:
luna -e <env> aurora tunnel statusExporting the connection string
Once the tunnel is running you can connect to the cluster directly using any Postgres client:
export DATABASE_URL="postgresql://username:password@localhost:5432/oltp"Credentials for named users are stored in Secrets Manager at <env>/aurora/users/<username>.
Running migrations remotely
The run-migration command handles the tunnel automatically — you do not need to start it manually first.
luna -e <env> aurora run-migration --database <database>Replace <database> with the target database name (e.g. oltp, activities). The command connects using the <env>/aurora/users/db-migrater secret, except for the activities database which uses the master credentials secret (<env>-aurora-credentials) because the aws_lambda extension requires rds_superuser.
Creating a user
luna -e <env> aurora create-user \
--username <name> \
--database <database> \
--file <filename>The --file argument is the filename of a SQL template from the CLI's bundled users/ directory — not an arbitrary path. Available templates:
default-user.sql— creates a login role with no grantstech-lead-user.sql— creates a login role with full DML access, schema creation rights, and default privileges for future objectstest-user.sql— creates a login role with full DML access on current and future tables, suitable for test environments
The SQL templates use , , and as placeholders, which the CLI substitutes before execution. A password is auto-generated if --password is not supplied.
The generated credentials are stored in Secrets Manager at <env>/aurora/users/<username>. A custom secret name can be specified with --secret-name, but it must start with <env>/aurora/users/.
Granting permissions for new tables
After running a migration that adds new tables, existing users need their permissions updated:
luna -e <env> aurora grant-permissions \
--username <name> \
--database <database> \
--file <filename>The --file argument is the filename of a SQL template from the CLI's bundled permissions/ directory — not an arbitrary path. Available templates:
db-migrater.sql— full privileges on all tables and sequences, plus schema creation rights (used by the migration role)read-only.sql—SELECTon all current and future tables and sequencestech-lead.sql— full DML and function execution on all current tables and sequences; run this after migrations to restore tech lead access to newly created objects
