Did you know that in October 2024, AWS introduced a significant update to the Lambda code editor in the console?
This new editor is built on the open-source foundation of Visual Studio Code (VS Code). If you’re accustomed to using VS Code as your Integrated Development Environment (IDE) for development and debugging, you’ll find the updated Lambda code editor strikingly familiar. It replicates the features and workflow of your desktop environment, bringing a seamless development experience to the AWS console.
In this article, I’ll walk you through the new Lambda code editor. We’ll explore the key updates, including improvements to the code editor itself, enhanced test event configurations, and streamlined function deployment and testing processes.
One standout feature of this editor is the ability to download the AWS SAM (Serverless Application Model) or CloudFormation
template for your Lambda function. This capability allows you to export the function’s code and infrastructure as code, enabling you to continue development locally in your preferred IDE. Once you’ve enhanced and tested the function locally, you can redeploy it as a new or updated Lambda function. The AWS Lambda console then provides an intuitive interface for accessing, testing, and validating your deployed function.
Let's look at the architecture/workflow diagram!
Overview of Lambda updated Console
The updated AWS Lambda console introduces several exciting features designed to enhance the developer experience. These include a VS Code-like interface, improved in-console functional code editing capabilities, and integrated support for Amazon Q's generative AI, empowering developers with intelligent assistance.
Below is an example of the updated editor interface.
Lambda Code
This is a very simple HelloWorld function code generated by Lambda. I have used AWS Console to create this function.
Lambda Test Event
Let's configure a test event. This test event will be used by the function during execution.
Please note that while this function does not take any parameter, I am still configuring the parameter. I will use this test event later as well when function is updated to accept a parameter.
A test event is created in a JSON format data object. This is the JSON format data object expected by the lambda function during execution.
Lambda Deployment & Validation
Once the code and test event are set up, it's time to deploy the function.
After the function is successfully deployed, you can test it using the configured test event in the AWS Console.
Based on the function code, the expected result is the message: "Hello from Lambda!", as shown below.
Lambda - SAM/CloudFormation Template
A noteworthy feature of the AWS Lambda Console is the option to view the SAM/CloudFormation template for the function you create. This template serves as a foundation for enhancing the function further in your local IDE. Once modified, you can redeploy the updated function seamlessly, leveraging the power of infrastructure-as-code for iterative development.
Download the template as AWS SAM file.
VS Code - Local Development, Testing and Deploy!
Now that I have the SAM template, I can use it to enhance the function in the local IDE. My local IDE setup includes VSCode along with AWS SAM CLI.
I have created several workshops that demonstrate how to develop and validate a Lambda function locally. If you are interested in those, Please watch those other videos. The links are provided in the description, and the videos are available in the playlist on my channel.
Since I am using Python 3.13, the latest version of the Python runtime, it is essential to have the latest AWS SAM CLI installed.
Update the code to enhance the function
I will add the ability to extract the parameter 'name' from event and update the output message that uses the value from this parameter.
Let's build the Lambda function code using the function code and downloaded SAM template.
SAM commands listed below can be used to build, validate and deploy the updated function.
- sam build
- sam local invoke -e
- sam deploy -g
If you prefer, you can now go back in your AWS Console and validate. You will see the function in the AWS Lambda function list.
Cleanup - Delete the Lambda function
Once you have completed the setup, ensure you delete the function to avoid unnecessary resource usage. If the function was created using the AWS Console, it must be deleted from the Console. Pay attention to any messages displayed on the screen during the deletion process. Additionally, if you created new roles, logs, or other associated resources, remember to delete those manually as well.
Conclusion
In this article, I demonstrated how to effectively use the updated Lambda code editor to develop, test, and deploy a Lambda function.
Additionally, I showcased how to download the SAM or CloudFormation template, continue development in the local VS Code IDE, validate the code locally, and deploy it to an AWS cloud region.
I hope you found this article helpful and informative!
Thank you for reading!
Watch the video here:
https://www.youtube.com/watch?v=sAnei-IzDOo
𝒢𝒾𝓇𝒾𝓈𝒽 ℬ𝒽𝒶𝓉𝒾𝒶
𝘈𝘞𝘚 𝘊𝘦𝘳𝘵𝘪𝘧𝘪𝘦𝘥 𝘚𝘰𝘭𝘶𝘵𝘪𝘰𝘯 𝘈𝘳𝘤𝘩𝘪𝘵𝘦𝘤𝘵 & 𝘋𝘦𝘷𝘦𝘭𝘰𝘱𝘦𝘳 𝘈𝘴𝘴𝘰𝘤𝘪𝘢𝘵𝘦
𝘊𝘭𝘰𝘶𝘥 𝘛𝘦𝘤𝘩𝘯𝘰𝘭𝘰𝘨𝘺 𝘌𝘯𝘵𝘩𝘶𝘴𝘪𝘢𝘴𝘵
Top comments (0)