Databases
Shuttle AWS RDS

This plugin provisions databases on AWS RDS using Shuttle. The following three engines are supported:

  • Postgres
  • MySql
  • MariaDB

​
Usage

Add shuttle-aws-rds to the dependencies for your service. Every engine is behind the following feature flags and attribute paths:

EngineFeature flagAttribute path
Postgrespostgresshuttle_aws_rds::Postgres
MySqlmysqlshuttle_aws_rds::MySql
MariaDBmariadbshuttle_aws_rds::MariaDB

​
Parameters

ParameterTypeDefaultDescription
local_uristrNoneRather connect cargo shuttle run to this database and don’t spin up a Docker instance of the database

When setting the local_uri you can also insert secrets from Secrets.toml using string interpolation. To insert the PASSWORD secret, pass it in like this:

#[shuttle_runtime::main]
async fn tide(#[shuttle_aws_rds::Postgres(
        local_uri = "postgres://postgres:{secrets.PASSWORD}@localhost:16695/postgres"
    )] pool: PgPool) -> ShuttleTide<MyState> { ... }

​
Example

This snippet shows the main function of a tide app that uses the shuttle_aws_rds::Postgres attribute to provision an RDS Postgres database. It gives you an authenticated sqlx Pool, which you can use to interact with the database.

main.rs
#[shuttle_runtime::main]
async fn tide(#[shuttle_aws_rds::Postgres] pool: PgPool) -> ShuttleTide<MyState> {
    pool.execute(include_str!("../schema.sql"))
        .await
        .map_err(CustomError::new)?;

    let state = MyState { pool };
    let mut app = tide::with_state(state);

    app.with(tide::log::LogMiddleware::new());
    app.at("/todo").post(add);
    app.at("/todo/:id").get(retrieve);

    Ok(app.into())
}

The full example can be found on GitHub