First of all, thanks to @softprops for building this tool and running it for several years.
If you're like me, you have some legacy projects using serverless-rust from the days when it was maintained. It was a great product that was irreplaceable when it launched and AWS didn't have great support for Rust.
But times have changed - the author has moved on to using SAM, and hey, open-source projects take a lot of time and effort to run. But now it's stuck in a broken state and you can't redeploy your once-working functions. It seems like this project has run its course.
But - fear not - it's easy to switch to the AWS-backed cargo lambda while sticking with serverless. I just did it in under 15 minutes. Here's how:
package:
individually: true
functions:
hello-world:
handler: does-not-matter-write-whatever
package:
# build with `cargo lambda build --output-format zip` and then fill in the build path. This is the default for `src/bin/hello_world.rs`
artifact: target/lambda/hello_world/bootstrap.zip
Step 5: Build
cargo lambda build --output-format zip
Now that you have support for it (since this is pending issue #119 in serverless-rust), you can easily switch to ARM if you want:
cargo lambda build --output-format zip --arm64
just also make the switch in your serverless.yml:
provider:
name: aws
architecture: arm64
Step 6: Deploy
Just like always. Now, instead of building the project (like serverless-rust did), it'll just pick up your .zip file. You'll probably want to update your build scripts to reflect this two-step workflow.
Hi everyone!
First of all, thanks to @softprops for building this tool and running it for several years.
If you're like me, you have some legacy projects using
serverless-rust
from the days when it was maintained. It was a great product that was irreplaceable when it launched and AWS didn't have great support for Rust.But times have changed - the author has moved on to using SAM, and hey, open-source projects take a lot of time and effort to run. But now it's stuck in a broken state and you can't redeploy your once-working functions. It seems like this project has run its course.
But - fear not - it's easy to switch to the AWS-backed
cargo lambda
while sticking withserverless
. I just did it in under 15 minutes. Here's how:Step 1: Install & RTFM
Check out https://www.cargo-lambda.info/
Step 2: [Optional] Uninstall
serverless-rust
just for sanity, to make sure it's fully out of your workflow.
serverless.yml
plugins
fieldStep 3: Select a Runtime
You'll want one of the OS-Only runtimes provided by AWS. I used
provided.al2023
but you may want something else.Replace this line:
with
Step 4: Update Your Function Handlers
Update your
serverless.yml
like so:Step 5: Build
Now that you have support for it (since this is pending issue #119 in
serverless-rust
), you can easily switch to ARM if you want:just also make the switch in your
serverless.yml
:Step 6: Deploy
Just like always. Now, instead of building the project (like
serverless-rust
did), it'll just pick up your.zip
file. You'll probably want to update your build scripts to reflect this two-step workflow.That's all!