shuttle-hq / shuttle

Build & ship backends without writing any infrastructure files.
https://shuttle.rs
Apache License 2.0
5.78k stars 242 forks source link

[Deployments]: AWS Lambdas #1551

Open jonaro00 opened 5 months ago

jonaro00 commented 5 months ago

Deploy AWS Lambdas using Shuttle


This issue is a part of the Product Feature Poll (all issues). React with :+1: if you want this feature. Comment if you have suggestions related to this feature.

3tilley commented 2 months ago

Pulling out a summary of this idea from a Discord discussion.

The proposal would be to accept user code and execute it on the Shuttle runtime in a Function-as-a-Service manner - made famous by AWS Lambda.

Benefits to the user

Benefits to Shuttle

Below is an example of what user code to register a Shuttle FaaS might look like:


#[derive(serde::Serialize)]
pub struct CalculationResult {
    z: f64,
}

#[derive(serde::Deserialize)]
pub struct CalculationInput {
    x: f64,
    y: f64,
}

pub enum Error {
    InternalError,
}

// More hands-on way of exposing a lambda-like endpoint
#[shuttle_runtime::faas_post("/mutliply")]
pub async fn multiply(input: CalculationInput) -> Result<CalculationResult, Error> {
    Ok(CalculationResult {
        z: input.x * input.y,
    })
}

// Could it be simplified such that someone would only need to do the below? Shuttle
// would then generate the JSON types
#[shuttle_runtime::faas_post("/multiply_simple")]
pub async fn multiply_simple(x: f64, y: f64) -> f64 {
    x * y
}

Things to think about:

shaaza commented 5 days ago

Adding some more benefits that a FaaS model might bring to both users and the platform, largely due to the request-scoped nature of FaaS: