Connect AWS RDS dedicated databases with your Rust applications on Shuttle
shuttle-aws-rds
dependency.
Each type of database is behind its own feature flag and macro attribute path.
Engine | Feature flag | Attribute path |
---|---|---|
Postgres | postgres | shuttle_aws_rds::Postgres |
MySQL | mysql | shuttle_aws_rds::MySql |
MariaDB | mariadb | shuttle_aws_rds::MariaDB |
sqlx::MySqlPool
for MySQL and MariaDB.
Lastly, add a macro annotaion to the Shuttle main function. Here are examples for Postgres:
sqlx
compile-time checked macros. Use cargo sqlx prepare
to enable offline building.Parameter | Type | Description |
---|---|---|
local_uri | &str | If specified, on local runs, use this database instead of starting a Docker container for it |
database_name | &str | Name to give the default database. Defaults to project name if none is given |
Secrets.toml
using string interpolation.
To insert the PASSWORD
secret, pass it in like this:
Secrets.dev.toml
, you need to set the same secret in Secrets.toml
to a empty string so that this step does not crash in deployment.local_uri
, then cargo-shuttle will attempt to spin up a Docker container and launch the database inside of it.
For this to succeed, you must have Docker installed and you must also have started the Docker engine. If you have not used Docker
before, the easiest way is to install the desktop app and then launch it in order to start
the Docker engine.
#[shuttle_aws_rds::Postgres]
attribute macro to provision an RDS Postgres database,
which can be accessed with an sqlx Pool.