Skip to main content

Command Palette

Search for a command to run...

Conjuring Code: Casting Your First AWS Lambda Spell (Part II of series: Lambda Lessons: Unlocking Serverless Computing)

Published
โ€ข5 min readโ€ขView as Markdown
Conjuring Code: Casting Your First AWS Lambda Spell (Part II of series: Lambda Lessons: Unlocking Serverless Computing)
L

Hey there! ๐Ÿ‘‹ I'm Hardeep Jethwani (HJ), your resident cloud aficionado and code maestro, proudly navigating the ever-changing seas of AWS Cloud and Full Stack Development for ~5 glorious years and counting. โ˜๏ธ๐Ÿ’ป

Currently, I'm orchestrating the tech symphony as part of Team HSBC Bank, where I'm on a mission to enhance the banking experience through the magic of technology. ๐Ÿš€๐Ÿ’ผ

In my past life at Capgemini, I led exciting adventures like migrating critical applications to the cloud (18 and counting!). I had databases waltzing into the AWS Cloud, sprinkling a bit of containerization magic along the way. AWS managed services like RDS, Lambda, ECS, and friends? They were my trusty sidekicks. ๐ŸŽฉ๐Ÿ”ง

When not automating deployments with CI/CD finesse (think AWS CodePipeline, CodeBuild, and CodeDeploy), you might find me designing infrastructure like a digital architect using AWS CloudFormation. Security is my jam โ€“ I've got WAF, Security Groups, MFA, Cognito, and even a secret club in private subnets to keep things safe. ๐Ÿ”’๐Ÿ’‚โ€โ™‚๏ธ

On top of all that, I'm on a mission to reduce carbon footprints because, why not? HSBC's commitment to sustainability is my heart and soul. We're going for NET ZERO carbon footprint, and I'm leading the charge, one container at a time! ๐ŸŒ๐ŸŒฑ

And yes, the fun doesn't stop at work. In my past life at Tata Consultancy Services, I co-created a multi-tier Point of Sale application with a global footprint, touching the lives of billions. My automation tools were so efficient that even Father Time was left scratching his head. โณ๐Ÿ’ก

If you're in need of a cloud-savvy comedian or a code deployment magician, look no further. Let's chat about tech, swap automation tales, or share some coding humor over a virtual coffee. Oh, and don't worry; I promise not to write code in my sleep (well, most of the time). Cheers to cloud adventures! โ˜•๐Ÿš€

Welcome back to our whimsical journey through the clouds in the Blog series "Lambda Lessons: Unlocking Serverless Computing". If you missed our initial foray into the magic of serverless computing, where we turned mere mortals into cloud wizards, check out Part-I. Now, buckle up as we dive into part 2, where we'll be casting our very first AWS Lambda spell (function).

The Adventure Continues: Your First AWS Lambda Function

So, you've decided to join the ranks of cloud sorcerers with AWS Lambda. Let's create something magical, shall we?

Step 1: The Summoning (Signing Up for AWS)

If you haven't already joined the AWS coven, it's time to sign up. Navigate to the AWS Management Console and pledge your allegiance. As a newcomer, you'll be granted access to the AWS Free Tier, which is like the cloud's version of a free trial potion.

Step 2: Entering the Secret Chamber (Navigating to the AWS Lambda Console)

Once you've crossed the threshold into the AWS realm:

  • Seek out โ€œServicesโ€ in the top menu, as if looking for a hidden spellbook.

  • Click on โ€œLambdaโ€ under โ€œComputeโ€ or you can directly search for "Lambda" in the search boxโ€” it's not guarded by a dragon, fortunately.

Step 3: The Incantation Begins (Creating a New Lambda Function)

Here, in the Lambda console:

  • Hit โ€œCreate functionโ€ like you're summoning a familiar.

  • Opt for โ€œAuthor from scratchโ€ because original spells are more potent.

  • Give your function a mystical name, like โ€œMyFirstLambdaSpell.โ€

  • Choose a runtime; AWS Lambda is multilingual, from the ancient tongues of Node.js to the runes of Python. Here in this blog, I have made use of Node.JS runtime. You can choose runtime according to your needs.

๐Ÿ’ก
For details on supported Lambda runtimes, refer to the AWS Lambda Runtimes White paper

Step 4: Bestowing Powers (Set Up Permissions)

Even wizards need permissions:

  • Choose โ€œCreate a new role with basic Lambda permissionsโ€ unless you've already conjured one before.

  • This role is like your function's magical amulet, granting it the power to perform tasks, like writing logs to Amazon CloudWatch.

  • Click on create function.

Step 5: The Spellcraft (Writing Your Function Code)

Now, for the heart of the spell:

  • In the โ€œFunction codeโ€ section, an editor awaits your incantations.

  • For a simple charm, let's write a function that echoes โ€œHello, Worldโ€ from the ethers.

Example in Node.js:

export const handler = async (event) => {
    console.log("Hello, World from Lambda!");
    return "Hello, World";
};
๐Ÿ’ก
The default function, "handler," can be customized, which we'll cover later. The "event" parameter holds details about what triggered the Lambda function, such as an S3 object upload, including event, bucket, and object names. Stay tuned for more on event objects and follow me on LinkedIn.
  • Don't miss packing your potion by hitting on the "Deploy" button

Step 6: Testing the Lambda Function (Configure Your Test Event)

Before unleashing your spell:

  • Hit โ€œTestโ€ to create a test event. The default potion (test request content) recipe should be sufficient, as we are not using any of the parameters in our Lambda function as of now.

  • Name your test Event, something like โ€œtestEventโ€ (you can name anything as per your convenience) and save it.

Step 7: Releasing the Magic (Testing Your Lambda Function)

  • With your potion ready, click โ€œTestโ€ once more.

  • If the stars align and your console returns โ€œHello, World,โ€ your spell has worked!

Step 8: Beyond the Veil (Explore More)

You've taken your first step into a larger world:

  • Experiment with different spells and incantations.

  • Consider binding your Lambda spell to other mystical AWS services.

A New Dawn

You've just scratched the surface of your potential as a cloud wizard. As you grow more comfortable with AWS Lambda, the realm of serverless computing will open up to you in ways you've never imagined. Keep experimenting, learning, and, most importantly, casting.

Stay tuned for the next chapter in our "Lambda Lessons" series, where we'll delve deeper into the arcane arts of AWS Lambda. Together, we'll uncover secrets that will make even the most seasoned sorcerers raise an eyebrow.

Thank you for being a part of this adventure. Until next time, happy cloud computing!!

If you have any questions, ideas, or experiences you'd like to share, I'm all ears. Let's keep the conversation going in the comments section below. And remember, this is just the beginning; there's a world of innovation waiting for you in the cloud. Stay curious, keep exploring, and keep making technology work for you. Follow me on social media, where I promise to share cloud wisdom with a side of chuckles:

  • LinkedIn: Connect with me on LinkedIn, where my cloud prowess is only rivalled by my talent for finding the perfect GIF for every situation. ๐Ÿš€๐Ÿ’ผ hardeepjethwani@LinkedIn

  • TopMate: Looking for a fellow cloud aficionado to share a virtual coffee with or brainstorm your next AWS masterpiece? Find me on TopMate! Because let's face it, cloud enthusiasts need to stick together. โ˜•๐Ÿค hardeepjethwani@topmate

  • Instagram: For behind-the-scenes glimpses of my cloud adventures and occasional 'AWS Gone Wild' stories that even AWS engineers find amusing. ๐Ÿ“ธ๐ŸŒฉ๏ธ hardeepjethwani@Instagram

  • X: Join the cloud conversation on Twitter, where I drop cloud knowledge and quirky cloud memes faster than you can say 'Elastic Beanstalk.' ๐Ÿฆโ˜๏ธ hardeepjethwani@X

So, whether you're seeking cloud advice, a good laugh, or simply a friendly chat about cloud and coffee preferences, I'm just a click away on these cloud-tastic platforms. See you in the cloudisphere, fellow cloud builders! ๐ŸŒโ˜๏ธ๐Ÿ˜„

Want to support my cloud adventures and keep the coffee flowing? Feel free to buy me a virtual coffee. After all, coffee is the secret sauce behind every successful cloud deployment. โ˜•๐Ÿ™Œ

#AWSLambda #ServerlessComputing #CloudComputing #TechTutorial, #ServerlessArchitecture #AWS #CloudTechnology #DevOps #Programming #SoftwareDevelopment

Lambda Lessons: Unlocking Serverless Computing

Part 2 of 2

Stay tuned for this upcoming Series .... ๐—Ÿ๐—ฎ๐˜‚๐—ป๐—ฐ๐—ต๐—ถ๐—ป๐—ด "๐—Ÿ๐—ฎ๐—บ๐—ฏ๐—ฑ๐—ฎ ๐—Ÿ๐—ฒ๐˜€๐˜€๐—ผ๐—ป๐˜€: ๐—จ๐—ป๐—น๐—ผ๐—ฐ๐—ธ๐—ถ๐—ป๐—ด ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ๐—น๐—ฒ๐˜€๐˜€ ๐—–๐—ผ๐—บ๐—ฝ๐˜‚๐˜๐—ถ๐—ป๐—ด"

Start from the beginning

AWS Lambda: Unleashing Serverless Magic for Muggles and Wizards Alike (Part I of series: Lambda lessons: Unlocking Serverless Computing)

Hey everyone, I'm super excited to start our "Lambda Lessons: Unlocking Serverless Computing" blog series. It's time to roll up our sleeves and dive deep into AWS Lambda, and I promise, it's going to be a fun ride, minus the actual cloud diving, of c...