AWS Lambda explained

AWS Lambda
Developer:Amazon.com
Operating System:Cross-platform
Language:English

AWS Lambda is an event-driven, serverless Function as a Service (FaaS) provided by Amazon as a part of Amazon Web Services. It is designed to enable developers to run code without provisioning or managing servers. It executes code in response to events and automatically manages the computing resources required by that code. It was introduced on November 13, 2014. [1]

Specification

Each AWS Lambda instance is a container created from Amazon Linux AMIs (a Linux distribution related to RHEL) and a configurable execution time. Node.js, Python, Java, Go,[2] Ruby,[3] and C# (through .NET) are all officially supported . In late 2018, custom runtime support[4] was added to AWS Lambda.

In 2019, at the AWS annual cloud computing conference (AWS re:Invent), the AWS Lambda team announced "Provisioned Concurrency", a feature that "keeps functions initialized and hyper-ready to respond in double-digit milliseconds."[5] The Lambda team described Provisioned Concurrency as "ideal for implementing interactive services, such as web and mobile backends, latency-sensitive microservices, or synchronous APIs."[6]

The Lambda Function URL gives Lambda a unique and permanent URL which can be accessed by authenticated and non-authenticated users alike.[7]

Lambda layer

AWS Lambda layer is a ZIP archive containing libraries, frameworks or custom code that can be added to AWS Lambda functions. [8] As of December 2024, AWS Lambda layers have significant limitations: [9] [10]

AWS Serverless Hero Yan Cui recommends alternative code-sharing strategies using package managers (e.g., NPM) due to these constraints.

Best practices

Following DevSecOps practices can help end-users to use and secure Lambda-based applications more effectively. [11] In Lambda-based applications, the line between the infrastructure and business logic is blurred and the apps are usually spread across various services. According to Yan Cui, to get the most value from testing efforts, Lambda-based applications should be tested mainly for their integrations, and unit tests should be used only if there is a complex business logic. Also, to make debugging and implementation of Lambda-based easier, developers should use orchestration within the bounded context of a microservice, and should use choreography between the bounded-contexts.[12]

Portability

Migration from AWS Lambda to other AWS compute services (e.g., Amazon ECS) can be challenging due to tight integrations with the service provider, a phenomenon known as service lock-in. Tools like AWS Lambda Web Adapter can facilitate portability by enabling developers to build web applications using familiar frameworks, employing the Lambdalith or Lambda monolith pattern. [13] [14] However, this approach has some limitations:

Hexagonal architecture can facilitate workload portability. It can help with both HTTP and non-HTTP APIs.

Testing

Testing integrations between services is crucial, particularly for serverless applications like AWS Lambda, due to their distributed and fragmented architecture. Simulator tools like LocalStack can facilitate testing but may yield false positives because they may diverge from actual AWS services. [15]

To address this limitation, Yan Cui introduced "remocal testing," enabling local execution of application code while interacting with genuine AWS services. This approach allows real-time debugging and rapid code modifications without deployment. However, it necessitates provisioning and subsequent decommissioning of AWS resources, requiring meticulous planning.

Helper Tools

Lambda Live Debugger is an open-source tools that helps you debug your AWS Lambda functions from your computer, while they are deployed in the cloud. It supports AWS CDK v2, Serverless Framework v3, AWS Serverless Application Model (SAM) and Terraform. [16]

Security

In April 2022, researchers found cryptomining malware targeting AWS Lambda named "Denonia".[17] [18] [19]

See also

Notes and References

  1. Book: Serverless Development on AWS Building Enterprise-Scale Serverless Solutions . O'Reilly Media . 9781098141899.
  2. Web site: Munns . Chris . January 15, 2018 . Announcing Go Support for AWS Lambda . December 10, 2019 . Amazon Web Services . October 15, 2019 . https://web.archive.org/web/20191015132051/https://aws.amazon.com/blogs/compute/announcing-go-support-for-aws-lambda/ . live .
  3. Web site: Munns . Chris . November 29, 2018 . Announcing Ruby Support for AWS Lambda . December 10, 2019 . Amazon Web Services . October 15, 2019 . https://web.archive.org/web/20191015132019/https://aws.amazon.com/blogs/compute/announcing-ruby-support-for-aws-lambda/ . live .
  4. Web site: November 29, 2018 . AWS Lambda Now Supports Custom Runtimes and Enables Sharing Common Code Between Functions . December 10, 2019 . Amazon Web Services . October 17, 2019 . https://web.archive.org/web/20191017111944/https://aws.amazon.com/about-aws/whats-new/2018/11/aws-lambda-now-supports-custom-runtimes-and-layers/ . live .
  5. Web site: 3 December 2019 . New – Provisioned Concurrency for Lambda Functions . 2020-10-12 . aws.amazon.com . 2020-10-18 . https://web.archive.org/web/20201018033719/https://aws.amazon.com/blogs/aws/new-provisioned-concurrency-for-lambda-functions/ . live .
  6. Web site: 2019-12-03 . New – Provisioned Concurrency for Lambda Functions . 2020-02-03 . Amazon Web Services . en-US . 2020-02-03 . https://web.archive.org/web/20200203223548/https://aws.amazon.com/blogs/aws/new-provisioned-concurrency-for-lambda-functions/ . live .
  7. Web site: Lambda function URLs - AWS Lambda . 2024-03-01 . docs.aws.amazon.com . 2024-03-01 . https://web.archive.org/web/20240301105416/https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html . live .
  8. Web site: Managing Lambda dependencies with layers . live . 2024-02-02 . 2024-02-04 . https://web.archive.org/web/20240204142231/https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html .
  9. Book: Sbarski, Peter . Serverless Architectures on AWS: With examples using AWS Lambda . 9781638351146.
  10. Book: Data Engineering with AWS: Learn how to design and build cloud-based data transformation pipelines using AWS . 9781800569041.
  11. Book: Katzer, Jason . Learning Serverless: Design, Develop, and Deploy with Confidence . O'Reilly Media . 2020 . 978-1492057017.
  12. Book: Cui, Yan . Serverless Architectures on AWS . Manning . 2020 . 978-1617295423 . 2nd.
  13. Web site: AWS Lambda Web Adapter . live . 2024-11-29 . 2024-11-28 . https://web.archive.org/web/20241128211006/https://github.com/awslabs/aws-lambda-web-adapter .
  14. Web site: The Lambda monolith . live . 2024-11-29 . 2024-11-26 . https://web.archive.org/web/20241126020340/https://docs.aws.amazon.com/lambda/latest/dg/monolith.html .
  15. Book: Stojanovic, Slobodan . Serverless Applications with Node.js Using AWS Lambda and Claudia.js . Manning . 9781638356172.
  16. Web site: Lambda Live Debugger . . 2024-10-04 . 2024-10-07 . https://web.archive.org/web/20241007091757/https://github.com/ServerlessLife/lambda-live-debugger . live .
  17. Web site: Archived copy . 2024-11-04 . 2024-11-15 . https://web.archive.org/web/20241115021350/https://www.cadosecurity.com/blog/cado-discovers-denonia-the-first-malware-specifically-targeting-lambda . live .
  18. Web site: Archived copy . 2024-11-04 . 2024-03-15 . https://web.archive.org/web/20240315230202/https://indianexpress.com/article/technology/crypto/cryptocurrency-mining-malware-used-to-target-aws-lambda-research-7859739/ . live .
  19. Web site: Archived copy . 2024-11-04 . 2024-04-05 . https://web.archive.org/web/20240405092229/https://therecord.media/researcher-finds-cryptomining-malware-targeting-aws-lambda . live .