🦀 The Crabby Lambda Book is Back! New Release & CDK Magic!

Lots of fixes, using the new Cargo-Lambda file structure, a new appendix on how to use CDK

If you are reading this is probably because you bought a copy of the e-book “Crafting Lambda Functions in Rust” by Luciano Mammino and James Eastham: A practical guide on how to build efficient, sustainable, cost-effective serverless AWS solutions with the Rust programming language. If not, and this topic sounds interesting to you, check out the book website at rust-lambda.com.

Hello, wonderful friends of the oxidized Lambda Function! 🦀

It's been a little quiet on our end lately, and we have to admit, the last couple of months haven’t left us much time to dedicate to the book. Let's just blame the Christmas holidays and January that roared in with a full schedule of work (which, let’s be honest, is probably a good thing).

Anyway, we are extremely grateful for your patience and especially to all of you who have reached out on various channels to provide valuable feedback on the book. We truly appreciate you taking the time!

We've been listening carefully, and now that we're back in the saddle, we’ve decided to resume work on the book with renewed energy! This means we've corrected a bunch of issues and updated some obsolete code (you know, how cargo-lambda loves to evolve, and for good reasons… more on it later).

So, get ready because a new, much more polished release of Crafting Lambda Functions in Rust is here, and it even includes some bonus content! 🎁

Let's dive in to see what's new and how you can get your hands on this new version!

But before we do, you deserve a huge thank you from the bottom of our hearts for supporting us with this project! Writing a book is epically hard work, but your enthusiasm and encouragement make it so much easier! We're also flabbergasted to see that almost 200 of you (198 to be accurate!) have bought the book so far. Thanks for trusting and supporting 2 unknown folks with an unfinished book! We'll make it worth it for you! ❤️

🗞️ What’s new

So, what’s New in This Release? The changes in this release can be condensed into three main categories, all aimed at making your journey with Crafting Lambda Functions in Rust even smoother and more enjoyable:

  1. Small Fixes, Big Impact: We've tackled a whole bunch of those pesky little gremlins – typos, minor inaccuracies, and inconsistencies. Thanks a million to all of you who’ve been sending in your reports! We especially want to give a shout-out to David Behroozi, Darko Mesaroš, and Gary Sassano for being especially active and sharp-eyed! Your contributions are invaluable to making this book the best it can be. Please, keep those reports coming! Every single one helps us get closer to the high-quality final version we’re aiming for.

  2. Code Modernization: We've updated all the code examples to align with the new code structure that’s now the default in newer versions of cargo-lambda. The main change here is the separation of the initialization and handler code into two distinct files. This keeps things nice and tidy and makes it easier to manage your projects. Don't worry, we’ll dive deeper into this new structure in a sec, so you'll be up to speed in no time!

  3. CDK Deployment Appendix: We've been incredibly inspired by the awesome work of Darko (yes, the same Darko from point #1!) and decided to add a new appendix that walks you through how to deploy your rusty Lambda functions using the AWS Cloud Development Kit (CDK)! So, if you’re a fan of CDK and prefer it over SAM as you work through the code samples in the book, this new section will make your life much easier!

Diving Deeper: The New cargo-lambda Code Structure

Let's talk a bit more about that code structure change we mentioned. When we first embarked on writing Crafting Lambda Functions in Rust, the cargo-lambda tool had a slightly different way of setting things up. Back then, when you used cargo lambda new or cargo lambda init, it would generate just one Rust file in your src directory, typically named main.rs.

This single main.rs file would house both the initialization logic (code that runs during the Lambda initialization phase) and the handler logic (the code that gets executed every time your function is invoked).

However, recent versions of cargo-lambda have introduced a more structured approach. Now, when you create a new Lambda function project, you’ll find two separate files generated:

  • main.rs: This file is now dedicated solely to the initialization code. It's where you set things up before the main function processing starts.

  • http_handler.rs (or event_handler.rs): This file contains the core handler logic for your Lambda function. If it’s an HTTP-based function, it will be named http_handler.rs by default. Otherwise, you’ll find it as event_handler.rs. This is where your function's work actually happens on each invocation.

The new file structure suggested by Cargo Lambda

This change has caused a little bit of confusion for some of our newer readers. What we were describing in the book didn't quite align with what was being generated in their environments, which made the code samples a little harder to follow and, potentially, debug.

This was something we were eager to address as a high priority! We wanted to make sure that your experience with the book and with cargo-lambda is as seamless and smooth as possible. By updating all the examples to reflect this new structure, we hope to remove any ambiguity and ensure that you're learning with the most up-to-date practices.

And the great news is, this change isn't just about keeping up with the times. This new, separated structure makes your code even more maintainable and, crucially, more testable! It’s a welcome improvement that’s beneficial to everyone and will pay dividends in the long run as you work on more complex projects.

New! Deploy with CDK: A Brand New Appendix

We've been getting a lot of great feedback from you, and one question that kept popping up was: "I love the book, but why did you choose SAM for deployment?“ or “Can I use CDK instead?".

Both are very legitimate questions… To answer the first one, we chose SAM initially because we feel it's a bit easier to grasp (and therefore easier to explain) if you're new to the world of Infrastructure as Code (IaC). SAM's simpler structure can be a gentler introduction to the concepts.

However, we totally get the appeal of using something more powerful and flexible like the AWS Cloud Development Kit (CDK). We use it ourselves in several projects and appreciate its expressiveness and advanced capabilities.

A 3D-rendered image of the new appendix about CDK! Tell us it sounds fancy because we wasted way too much time on it! 😅

So, in this release, we're excited to announce that we've added a brand new appendix dedicated to deploying your Rust Lambda functions with CDK! We were also inspired by an awesome example that Darko shared with us, which helped us finally take the plunge and get this appendix in the book.

This new appendix, located at the very end of the book, provides a quick tutorial on how to create a Rust Lambda function resource within a CDK stack. It also shows you how to compile it at deployment time using a handy construct provided by the cargo-lambda-cdk package. And a big shoutout here goes to the wonderful David Calavera, the maintainer of both cargo-lambda and cargo-lambda-cdk (and also one of our amazing reviewers!). Remember you can sponsor David on GitHub if you also value his work!

We're confident you'll appreciate this addition to the book and that it will make your journey into using Rust for your Lambda functions even more enjoyable and flexible. Whether you're a SAM enthusiast or a CDK fanatic, we hope we've got you covered!

And we’re not stopping there! We’re planning to add even more appendices to cover other popular IaC tools. The second most requested option so far has been Terraform. So, if you have a preference for using other tools in your day-to-day work – perhaps the Serverless Framework or Pulumi? – please let us know! Your feedback will help us guide our future additions and ensure we're providing you with the most useful resources possible.

📦 How to get the new release

If you already have a copy of Crafting Lambda Functions in Rust, grabbing the latest release is easy-peasy, lemon squeezy! 🍋

  1. Head over to Gumroad, log in, and open up your product library.

  2. You’ll see a list of all your purchased products—look for “Crafting Lambda Functions in Rust (e-book)”.

  3. Click on it, and voilà! You’ll find all the updated download links right there.

All updated code examples are also available in our code repository, so you can dive into the latest examples straight away.

If you hit any snags along the way, reach out—we’re here to help!

👂 We want to hear your feedback

Your thoughts mean the world to us. Whether it’s a suggestion, a favorite section, or something you found unclear, we’d love to know. Connect with us on Discord or via email and let us know how the book’s been treating you!

And, if you’re feeling extra generous, please consider leaving a review on Gumroad. Every review helps us grow and reach more readers. We just received our first review from an anonymous fan, and it made our day! But they say there’s no such thing as too many reviews, so if you’ve got a spare 3 minutes, a few lines on Gumroad would be amazing. We are even featuring some of them on our website!

💌 Reader's Spotlight: Darko's Impressive URL Shortener!

Remember that mysterious project we hinted at earlier when mentioning Darko? Well, get ready to be impressed! Inspired by what he learned from Crafting Lambda Functions in Rust, Darko has built a fully-featured URL shortener (which even includes a frontend side!).

krtk.rs - A URL-shortener powered by Rust and Lambda!

We're absolutely thrilled to see folks like Darko taking the concepts and techniques we cover in the book and building such fantastic and complete projects. It's incredibly rewarding to see the community actively applying what they've learned and even pushing the boundaries beyond what we've showcased!

Darko's URL shortener is a perfect example of the power and flexibility that Rust and AWS Lambda offer. It’s an amazing project that not only shows off his skills but is also a valuable resource for the community.

The code is entirely open-source and available on GitHub, so you can explore it, learn from it, and maybe even contribute to it! You can find it here: https://github.com/darko-mesaros/krtk.rs.

🔮 What’s next

There’s still plenty more to cover in the book, and we’re excited to share what’s next! We’ll be diving back in with renewed energy, pouring our hearts and minds into the upcoming chapters. If you’ve been following along, you might have a good idea of what’s coming next! 😉

Stay tuned for the next release, and in the meantime, if you have any thoughts or suggestions, don’t be a stranger! We're always eager to hear your feedback and ideas.

Until next time,

— Luciano & James

P.S. We're both thrilled to announce that we’ll be delivering the closing keynote at Rust Global in London on February 21st (that’s just two weeks away, no pressure!). We’ll be sharing our experience in building Lambda Functions using Rust and making a case for why we believe this is the perfect use case to introduce Rust into your company and quickly reap its benefits with minimal risk. If you’ll be in London that day, please come and say hi – we’d love to chat with you and we will bring shiny stickers of our lovely crab mascot! 🦀 

Reply

or to participate.