- Postgres
- MySQL
- MariaDB
This resource is available on the Pro tier and up. Provisioning it incurs additional charges, except
on the Growth tier, where the first instance is included. For details, see our
pricing page.
RDS vs Shared DB
- Dedicated Instance: Each AWS RDS database is it’s own dedicated instance.
- Stability and Security: AWS RDS has greater stability due to it being a service directly offered by AWS, and also greater security due to being a dedicated instance.
- Flexible: AWS RDS instances on the Shuttle platform can be customised to suit your needs. Instance size can be increased from the default and AWS RDS features can be enabled or disabled.
- Postgres
- MySQL
- MariaDB
- Postgres
Default RDS Instance
The RDS instance created by Shuttle has the following specifications and features by default:- 2 vCPU
- 1 GB Memory
- 20 GiB Storage
- Backups Disabled
- Single Availability Zone
- 1 Node
- No Proxy
Usage
Please contact us to enable RDS resources for your account. Then, add theshuttle-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 |
Output type
This resource supports the same output types as Shared DB Postgres, along withsqlx::MySqlPool
for MySQL and MariaDB.
Lastly, add a macro annotaion to the Shuttle main function. Here are examples for Postgres:
The Shuttle builder does not currently support
sqlx
compile-time checked macros. Use cargo sqlx prepare
to enable offline building.Parameters
All of the AWS RDS macros take the same optional parameter: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:
Caveat: If you are interpolating a secret from
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.
Connection string
After deploying a project with a database macro, you can view the connection string with credentials with:Example
This snippet shows the main function of an Axum app that uses the#[shuttle_aws_rds::Postgres]
attribute macro to provision an RDS Postgres database,
which can be accessed with an sqlx Pool.
main.rs