AWS Lambda: Difference between revisions

Content deleted Content added
m Removed an unnecessary section
Re-arranged the existing texts for better clarity and removed the unnecessary sections because Wikipedia is not a manual.
Line 11:
 
'''AWS Lambda''' is an [[event-driven programming|event-driven]], [[Serverless computing|serverless]] [[Function as a service|Function as a Service]] (FaaS) provided by [[Amazon.com|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 [[Event (computing)|events]] and automatically manages the computing resources required by that code. It was introduced on November 13, 2014.<ref>{{cite web |url=https://aws.amazon.com/blogs/aws/run-code-cloud/ |title=AWS Lambda – Run Code in the Cloud |date=November 13, 2014 |first=Jeff |last=Barr |website=AWS News Blog |access-date=August 29, 2022}}</ref>
 
Note that in Lambda-based applications the line between the infrastructure and business logic is blurred and the apps are usually spread across various services. To get the most value from testing, a Lambda-based application should be tested mainly for its integrations; and unit tests should be used only if there is a complex business logic. <ref name=":1">{{Cite book |title=Serverless Architectures on AWS |publisher=Manning |year=2020 |isbn=978-1617295423 |edition=2nd}}</ref><ref>{{Cite book |title=Learning Serverless |publisher=O'Reilly Media |year=2020 |isbn=9781492056966}}</ref>
 
Following [[DevSecOps]] practices can help you to use and to secure Lambda-based applications more effectively. <ref>{{Cite book |last=Katzer |first=Jason |title=Learning Serverless: Design, Develop, and Deploy with Confidence |publisher=O'Reilly Media |year=2020 |isbn=978-1492057017}}</ref>
 
To make debugging and implementation of Lambda-based applications easier, developers are advised to use [[Orchestration (computing)|orchestration]] within the [[Domain-driven design|bounded context]] and to use [[Service choreography|choreography]] between the bounded-contexts.<ref name=":1" />
 
==Specification==
Line 35 ⟶ 29:
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."<ref>{{cite web |date=3 December 2019 |title=New – Provisioned Concurrency for Lambda Functions |url=https://aws.amazon.com/blogs/aws/new-provisioned-concurrency-for-lambda-functions/ |access-date=2020-10-12 |website=aws.amazon.com}}</ref> The Lambda team described Provisioned Concurrency as "ideal for implementing interactive services, such as web and mobile backends, latency-sensitive microservices, or synchronous APIs."<ref>{{Cite web |date=2019-12-03 |title=New – Provisioned Concurrency for Lambda Functions |url=https://aws.amazon.com/blogs/aws/new-provisioned-concurrency-for-lambda-functions/ |access-date=2020-02-03 |website=Amazon Web Services |language=en-US}}</ref>
 
== AWS Lambda Function URL ==
The Lambda Function URL gives Lambda a unique and permanent [[URL]] which can be accessed by [[authenticated]] and non-authenticated users alike.<ref name=":0">{{Cite web |title=Lambda function URLs - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html |access-date=2024-03-01 |website=docs.aws.amazon.com}}</ref> It was launched in April 6, 2022 by the AWS Lambda team.<ref>{{Cite web |title=Document history - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/lambda-releases.html |access-date=2024-03-01 |website=docs.aws.amazon.com}}</ref>
 
=== Format ===
A typical function URL has the following format: <ref name=":0" /><syntaxhighlight lang="text">
https://<url-id>.lambda-url.<region>.on.aws
</syntaxhighlight>
 
=== History ===
Before Function URLs, Lambda functions could be invoked only using AWS Lambda [[API|APIs]] or [https://aws.amazon.com/api-gateway/ Amazon API Gateway].<ref>{{Cite web |title=Invoking Lambda functions - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html |access-date=2024-03-01 |website=docs.aws.amazon.com}}</ref> [[Streaming data|Response streaming]] was also made possible with function URLs.<ref>{{Cite web |title=Configuring a Lambda function to stream responses - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html#config-rs-invoke-furls |access-date=2024-03-01 |website=docs.aws.amazon.com}}</ref>
 
=== Pricing ===
There are no extra charges included with invoking a Function URL, other than the duration and [[HTTP|requests]].<ref>{{Cite web |title=Serverless Computing – AWS Lambda Pricing – Amazon Web Services |url=https://aws.amazon.com/lambda/pricing/ |access-date=2024-03-01 |website=Amazon Web Services, Inc. |language=en-US}}</ref> Function URLs are included in Lambda’s request and duration pricing.<ref>{{Cite web |date=2022-04-06 |title=Announcing AWS Lambda Function URLs: Built-in HTTPS Endpoints for Single-Function Microservices {{!}} AWS News Blog |url=https://aws.amazon.com/blogs/aws/announcing-aws-lambda-function-urls-built-in-https-endpoints-for-single-function-microservices/ |access-date=2024-03-01 |website=aws.amazon.com |language=en-US}}</ref>
 
==== Caution with a public function URL ====
If a Lambda function URL is made publicly available with AuthType = NONE, it will warrant unauthenticated access to the Lambda function.<ref>{{Cite web |title=Security and auth model for Lambda function URLs - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html |access-date=2024-03-01 |website=docs.aws.amazon.com}}</ref> It can lead to a [[Denial-of-service attack|DDoS]] attack, which will incur costs to the [[Amazon Web Services|AWS]] account which is hosting the Lambda function.
 
== AWS Lambda Layers ==
AWS Lambda Layers allow developers to easily manage and share common components across multiple Lambda functions. It's designed to promote code reusability and simplify the deployment of libraries, custom runtimes, and other dependencies that Lambda functions might need. Lambda Layers can be particularly useful in microservices architectures, where multiple functions might share the same dependencies.<ref>{{Cite web |date=2022-08-11 |title=Building Serverless SaaS Microservices with AWS Lambda Layers {{!}} AWS Partner Network (APN) Blog |url=https://aws.amazon.com/blogs/apn/building-serverless-saas-microservices-with-aws-lambda-layers/ |access-date=2024-02-02 |website=aws.amazon.com |language=en-US}}</ref> By using layers, one can ensure that all functions are using the same version of a library, making the application more consistent and easier to manage.
 
A Lambda Layer is a .zip file archive that allows to package and deploy common components separately from a Lambda function code.<ref>{{Cite web |title=Working with Lambda layers - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html |access-date=2024-02-02 |website=docs.aws.amazon.com}}</ref> A single AWS Lambda function can include up to five layers at a time. The layers are applied in a specified order, allowing later layers to override the content of earlier ones if there are conflicts.<ref>{{Cite web |title=Adding layers to functions - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/adding-layers.html |access-date=2024-02-02 |website=docs.aws.amazon.com}}</ref> This layering system can significantly reduce the size of Lambda deployment packages, as there is no need to include these common components in every function's deployment package.
==Best practices==
 
Following [[DevSecOps]] practices can help you to use and to secure Lambda-based applications more effectively. <ref>{{Cite book |last=Katzer |first=Jason |title=Learning Serverless: Design, Develop, and Deploy with Confidence |publisher=O'Reilly Media |year=2020 |isbn=978-1492057017}}</ref> 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 to 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 (computing)|orchestration]] within the [[Domain-driven design|bounded context]] of a [[Microservices|microservice]], and should use [[Service choreography|choreography]] between the bounded-contexts.<ref>{{Cite book |last=Cui |first=Yan |title=Serverless Architectures on AWS |publisher=Manning |year=2020 |isbn=978-1617295423 |edition=2nd}}</ref>
=== Usage ===
'''Create a Lambda Layer:''' One first creates a layer by packaging libraries or other dependencies into a .zip file and then uploading it to Lambda.<ref>{{Cite web |title=Packaging your layer content - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/packaging-layers.html |access-date=2024-02-02 |website=docs.aws.amazon.com}}</ref> The runtimes that the layer is compatible with can be specified when creating a layer.<ref>{{Cite web |title=Creating and deleting layers in Lambda - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/creating-deleting-layers.html |access-date=2024-02-02 |website=docs.aws.amazon.com}}</ref>
 
'''Add the Layer to Lambda Functions:''' When creating or updating a Lambda function, the layers to be included in the function can be specified. The Lambda service will then merge function code with the specified layers to create the execution environment.<ref>{{Cite web |title=Adding layers to functions - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/adding-layers.html |access-date=2024-02-02 |website=docs.aws.amazon.com}}</ref>
 
'''Versioning:''' Each time a new version of a layer is published, it receives a unique version number.<ref>{{Cite web |title=Working with Lambda layers - AWS Lambda |url=https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html#lambda-layer-versions |access-date=2024-02-02 |website=docs.aws.amazon.com}}</ref> This is useful for managing updates to layers separately from function code. It also ensures that functions can continue using older versions of a layer if needed.
 
'''Sharing Layers:''' Layers can be shared across different AWS accounts or made public to the broader AWS community.<ref>{{Cite web |title=Sharing Lambda Layers - AWS Serverless Application Repository |url=https://docs.aws.amazon.com/serverlessrepo/latest/devguide/sharing-lambda-layers.html |access-date=2024-02-02 |website=docs.aws.amazon.com}}</ref> This is particularly useful for commonly used libraries or runtime extensions.
 
==See also==