Demystify the DX for Lambda functions

Rate this content
Bookmark

In this session, I share with you how AWS CDK and AWS Toolkit can simplify the developer experience to run serverless workloads in the cloud

A session with no slides, just an IDE and a CLI for deploying an API in the cloud, update it quickly, and retrieve logs without leaving your favourite IDE!

Luca Mezzalira
Luca Mezzalira
30 min
15 Feb, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Welcome to this session on Lambda Developer Experience. Learn about using AWS Cloud Development Kit (CDK) to write code in your favorite language and automatically generate CloudFormation templates. Test locally with the SAM CLI and deploy with CDK. Accelerate testing and updates with CDK flags. Use the AWS Toolkit to invoke Lambda functions, analyze logs, and generate code with Application Composer.

1. Introduction to Lambda Developer Experience

Short description:

Welcome to this session about Lambda Developer Experience. Discover tools to properly develop serverless workloads using Lambda function directly with Visual Studio Code or IntelliJ.

Hi, and welcome to this session about Lambda Developer Experience. How often you have found yourself that you are deploying your Node.js workload on the cloud and you need to wait for CloudFormation or Terraform or whatever else that has to deploy all your code every single time, despite you change maybe one line of code, the feedback loop that you have in order to wait for the deployment is pretty long. Sometimes you go out for a coffee, maybe you lose the momentum, and therefore, today I want to show you what are the tools that are available for you to develop properly a serverless workload using Lambda function, your favorite compute service directly with Visual Studio Code or IntelliJ because all the things that I'm going to show you today are going to be valid for VS Code as well as IntelliJ.

2. Using AWS Cloud Development Kit (CDK)

Short description:

AWS Cloud Development Kit (CDK) is an infrastructure as code tool provided by AWS. It allows you to write code in your favorite language and automatically generates a CloudFormation template for deployment. Let's look at an example: a simple Hello World application using ESM with nodes and CDK. CDK lets you write TypeScript and extends the Lambda function with additional capabilities like bundling options using ESBuild. Deploying the solution is as simple as running 'cdk deploy' and choosing the profile with the necessary information. CDK will handle the deployment, including the creation of an HTTP API acting as a proxy through API Gateway. Once deployed, you can access the API using the provided URL.

So let's start. First of all, what we are going to use today is AWS Cloud Development Kit, CDK as everyone refers to, is one of the infrastructure as code tools that are offered by AWS and allows you to write with your favorite language and then automatically behind the scene when we are building our artifact, what happens is that we are generating a CloudFormation template that will be then used for the deployment and provisioning of your code and infrastructure.

Now, let's try to see an example. I prepared a couple of examples so we can start to look into that. So the first example here is about a very simple Hello World example. I created this template for using ESM with nodes and using CDK for defining my infrastructure. So as you can see here, the beauty of CDK is I'm writing TypeScript that is in this case my favorite language for writing CDK. And here I have a high-level construct like node.js function that is extending the Lambda function. So as you can see here, it's extending this construct, this low-level construct that is called Lambda.function and it's adding new capabilities like the possibility to add bundling options. By default, CDK offers you the possibility to use ESBuild and therefore why not leverage that for making our bundle size smaller. So as you can see here, I use the bundling with a bunch of configuration that allows me to have the possibility to use ESM modules as well as other capabilities like top-level await for instance.

And now if we want to deploy this solution in an AWS account, it is as simple as writing here cdk deploy and then I decide which profile that I configure multiple profile in my machine I want to use where I have the region, I have my information needed in order to deploy this workload on the cloud. Now it's the first time that I'm doing that. So as you can see, CDK is telling me, oh by the way, there are a few things that you need to deploy, that are all the things in green. As you can see here, that will be needed in order to have this API up and running inside my system. So okay, so this one is as simple as a lambda function with an HTTP API that acts as a proxy that shows as API gateway the possibility to expose your API. So in one minute, this will be up and running and available on the cloud. And in the meantime, we can see that here we have the definition of my hello ESM lambda. Then we have an HTTP API definition that you can easily do with CDK. I just create the integration that basically is allowing you to have all the roles and settings needed in order to wire on a specific route your lambda function. And here you have the path that is the root path, the method that you can invoke this specific lambda function. And that's basically what you get. And at the end, we are going to have also this construct, this CFN output, basically it highlights inside your command line, the URL where you can find this API. As simple as that. So now we have deployed everything. As you can see, we have a URL that is useful. So if everything goes well, we should have our API up and running. And here we are. We have hello node ESM module. That is exactly what we have here, as you can see.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

AWS Lambda under the hood
Node Congress 2023Node Congress 2023
22 min
AWS Lambda under the hood
Top Content
In this talk I explain how the AWS Lambda service works explaining the architecture, how it scales and how a developer should think about when they design their software using Lambda functions
AWS Lambda Performance Tuning
Node Congress 2024Node Congress 2024
25 min
AWS Lambda Performance Tuning
Have you ever wonder how to get the best out of your Lambda functions?If so, this talk will reveal the behind the scene one of the most popular serverless service and you will be exposed to a step by step guidance for optimizing your functions.During this session, I will walk you through the mindset to reduce your Lambda functions execution time. In the example presented I was able to reduce the execution time by 95% for warm start and over 50% with cold starts improving also the transactions per seconds served with this API.
Building Real-time Serverless GraphQL APIs on AWS with TypeScript and CDK
React Summit 2020React Summit 2020
25 min
Building Real-time Serverless GraphQL APIs on AWS with TypeScript and CDK
CDK (Cloud development kit) enables developers to build cloud infrastructure using popular programming languages like Python, Typescript, or JavaScript. CDK is a next-level abstraction in infrastructure as code, allowing developers who were traditionally unfamiliar with cloud computing to build scalable APIs and web services using their existing skillset, and do so in only a few lines of code.
In this talk, you’ll learn how to use the TypeScript flavor of CDK to build a hyper-scalable real-time API with GraphQL, Lambda, DynamoDB, and AWS AppSync . At the end of the talk, I’ll live code an API from scratch in just a couple of minutes and then test out queries, mutations, and subscriptions.
By the end of the talk, you should have a good understanding of GraphQL, AppSync, and CDK and be ready to build an API in your next project using TypeScript and CDK.
Automate React Site Deployments from GitHub to S3 & CloudFront
DevOps.js Conf 2021DevOps.js Conf 2021
33 min
Automate React Site Deployments from GitHub to S3 & CloudFront
In this talk, I will demonstrate how to create a CI/CD pipeline for a React application in AWS. We'll pull the source code from GitHub and run tests against the application before deploying it to an S3 bucket for static site hosting. The site will then be distributed using CloudFront which will point to the S3 bucket. All of the infrastructure will be built using Terraform. In addition, I'll make use of Terragrunt to show how to create this setup for multiple environments.
Infrastructure as Code for React Application on AWS Written in TypeScript
React Advanced Conference 2021React Advanced Conference 2021
30 min
Infrastructure as Code for React Application on AWS Written in TypeScript
We consider what IaC (Infrastructure as Code) is and why we should invest our time/money into it. It’s going to be a workshop-style talk and as the result, the end of it you will have complete infrastructure as code for React application on AWS written in TypeScript
Building a sophisticated CodePipeline with CDK in a Monorepo Setup
DevOps.js Conf 2024DevOps.js Conf 2024
8 min
Building a sophisticated CodePipeline with CDK in a Monorepo Setup
Many companies are going all-in AWS and thus adopting their complete CodeSuite for their CI/CD processes. However, while CodePipeline is the platform for this process, it may not be the most user-friendly. In a Monorepo setup, it's typical to create multiple CI/CD pipelines for each package. However, there are several caveats to be aware of. For instance, you may encounter scenarios where multiple pipelines get triggered even if you just modified one file, or you may question the need to create multiple branches for each pipeline. In this talk, we provide valuable tips for building a sophisticated CodePipeline using CDK in a Monorepo environment. The techniques discussed in this talk are also transferrable to other CI/CD tools.

Workshops on related topic

Building Serverless Applications on AWS with TypeScript
Node Congress 2021Node Congress 2021
245 min
Building Serverless Applications on AWS with TypeScript
Workshop
Slobodan Stojanović
Slobodan Stojanović
This workshop teaches you the basics of serverless application development with TypeScript. We'll start with a simple Lambda function, set up the project and the infrastructure-as-a-code (AWS CDK), and learn how to organize, test, and debug a more complex serverless application.
Table of contents:        - How to set up a serverless project with TypeScript and CDK        - How to write a testable Lambda function with hexagonal architecture        - How to connect a function to a DynamoDB table        - How to create a serverless API        - How to debug and test a serverless function        - How to organize and grow a serverless application


Materials referred to in the workshop:
https://excalidraw.com/#room=57b84e0df9bdb7ea5675,HYgVepLIpfxrK4EQNclQ9w
DynamoDB blog Alex DeBrie: https://www.dynamodbguide.com/
Excellent book for the DynamoDB: https://www.dynamodbbook.com/
https://slobodan.me/workshops/nodecongress/prerequisites.html
Frontend to the Cloud Made Easy - A ReactJS + AWS Workshop
DevOps.js Conf 2024DevOps.js Conf 2024
59 min
Frontend to the Cloud Made Easy - A ReactJS + AWS Workshop
Workshop
Eyal Keren
Eyal Keren
This workshop enables you to learn how to develop React applications, and then deploy them to the cloud (or building them to the console) coupled with a backend, fully abstracted, with no complex backend configuration, simplifying the building and deployment of frontend & web apps to the cloud.