AWS

Essential Lambda Concepts | AWS

AWS Lambda is a computing service that runs the back-end code in response to events such as object upload to Amazon S3 buckets, updates to Amazon DynamoDB table data, Amazon kinesis dreams, etc. once the code is uploaded to Lambda, the service handles all the capacity, scaling, patching, and administration of the infrastructure to run the code.

Key concepts of Lambda are written below

Let’s start with the essential concepts of AWS Lambda.

Function

Generally, the function is referred to as a block of code that can be considered as input, and it is processed to gather output. AWS provides the lambda service so that users can create a lambda function, and it can be edited to be used according to the requirement. A lambda function can be created from the AWS Lambda dashboard by simply typing the name of the function so it can be identified from the list of functions. Runtime is another requirement while creating a function in Lambda so it can be used in a certain environment:

The user can add a trigger to the lambda function which is discussed below.

Trigger

A trigger activates the lambda function through a specific event. The user can attach multiple triggers with a function to execute them several times. Each trigger must be used for its purpose otherwise, it will be a waste of a resource, space, and others. The trigger can be attached to a created function, and each function can be identified through a given name.

In the image, the API gateway is added, which contains an “API endpoint” to use the trigger.

Event

An event is created to invoke the lambda function and it is represented in a JSON document that has the data for the functions to execute or process. If an image is uploaded in the Amazon S3 bucket and the user wants to create its thumbnail. The user will connect S3 to the Lambda function, which should create the thumbnail of an image whenever it is uploaded to the S3 bucket. The data of the image which is to be converted will be received by the lambda function and stored in the event.

Note: A lambda function must contain the event as it is the entry point of the function.

Execution Environment

A developer can use the Execution environment of the lambda function to write its code to be executed. The runtime of the function communicates with the API runtime, and then it is directed to the lambda service.

The runtime environment is available in the “Code” section so the developer can edit it:

After that, the next concept is Instruction set architecture.

Instruction Set Architecture

It determines the processor of the system on which the lambda function is being used, and the following architectures can be used to create a lambda function:

  • Use “arm64 – 64-bit ARM” architecture”, for the AWS Graviton2 processor
  • Use “x86_64 – 64-bit x86” architecture”, for x86-based processors

The user needs to choose one of these architectures according to their function code.

Deployment Package

The user can deploy a lambda function code using deployment packages in the following forms:

  • Container images
  • Zip file archives
  • Layers
  • Using Other services to deploy packages

Use any way of deploying packages to upload the code of the lambda function.

Runtime

The runtime provides the environment to use a specific language for the AWS lambda code. It is a language-specified environment that allows the user to run its code in the executable environment. A few of the runtime environments are mentioned below:

  • NodeJS
  • Python
  • Ruby

If the code is to be uploaded through a zip file, then the runtime must match the language of the code.

Layer

The layer can be used to store a block of lambda function code which could be a library or a module, and it can be used across multiple services. It also makes the lambda code smaller as a bunch of code blocks are stored in different layers and can be used at any moment. The user can add new layers and also edit the already created layer from the platform:

The layers are added to ease the lambda function, and the next essential concept is the destination.

Destination

It is the ability to invoke asynchronous lambda function and It does not make the user wait for the lambda execution to be finished as earlier the user needs to wait for the lambda function execution to be complete. The destination can be simply added from the platform by clicking on the “Add destination” button connected to the lambda function:

This guide has successfully explained the Essential Lambda Concepts.

Conclusion

The essential concepts of the Amazon Lambda service have been discussed in this guide. The user can create a lambda function from the lambda dashboard and then create a trigger to attach to it. The trigger will invoke the lambda function to execute when a certain event occurs. An event is the entry point for the Lambda function and the runtime environment in Lambda can be used to write code in a specific language.

About the author

Talha Mahmood

As a technical author, I am eager to learn about writing and technology. I have a degree in computer science which gives me a deep understanding of technical concepts and the ability to communicate them to a variety of audiences effectively.