Lambda Functions
Lambda is a serverless computing platform provided by AWS that allows you to run code without provisioning or managing servers. It enables you to build and run applications in response to events or triggers from Lambda Functions.
Lambda Functions are event-driven and designed to perform small, specific tasks or functions. They can be written in supported programming languages such as Python, JavaScript (
Node.js
), Java, C#, PowerShell, or Ruby. Once you create a Lambda function, you can configure it to respond to various types of events, such as changes in data stored in an Amazon S3 bucket, updates in an Amazon DynamoDB table, incoming HTTP requests via Amazon API Gateway, or custom events triggered by other AWS services.Using Lambda, you write your code and upload it to AWS. Lambda executes and scales the code as needed, abstracting away the underlying infrastructure, and allowing you to focus on writing the actual business logic of your application. Lambda Functions are the principal resource of the Lambda serverless platform.
In a Zip package, the Lambda Function code resides at the root of the package. If you are using a virtual environment, all dependencies should be packaged.
Refer to the AWS documentation for detailed instructions on how to generate the package, using tools such as Zappa and Serverless.
- 2.
- 3.Upload the Zip package in the AWS Console.
- 1.In the DuploCloud Portal, navigate to DevOps -> Serverless.
- 2.Click the Lambda tab. The Lambda Function page displays.
- 3.Click Add. The Create a Lambda Function page displays.Create a Lambda Function page using Type Zip
- 4.In the Name field, enter the name of your Lambda Function.
- 5.In the Description field, enter a useful description of the function.
- 6.From the Package Type list box, select Zip. For type Image, see the Configure Lambda with Container Images topic.
- 7.In the Runtime field, enter the runtime for the programming language you are using.
- 8.In the Function Handler field, enter the method name that Lambda calls to execute your function.
- 9.Click Submit. The Lambda Function is created.
- 10.On the Lambda Function page, from the Name column, select the function you created.
- 11.From the Actions menu, click Console. You are redirected to the AWS Console.Actions menu on the selected Lambda Function page
- 12.Test the function using the AWS Console.
DuploCloud enables you to create a classic micro-services-based architecture where your Lambda function integrates with any resource within your Tenant, such as S3 Buckets, Dynamo database instances, RDS database instances, or Docker-based microservices. DuploCloud implicitly enables the Lambda function to communicate with other resources but blocks any communication outside the Tenant, except Elastic Load Balancers (ELB).
To set up a trigger or event source, create the resource in the DuploCloud Portal. You can then trigger directly from the resource to the Lambda function in the AWS console menu of your Lambda function. Resources can be S3 Buckets, API gateways, DynamoDB database instances, and so on.
Passing secrets to a Lambda function can be done in much the same manner as passing secrets to a Docker-based service using Environmental Variables. For example, you can create a relational database from the Database -> RDS menu in DuploCloud, providing a Username and Password. In the Lambda menu, supply the same credentials. No secrets need to be stored in an AWS Key Vault, a Git repository, and so on.
To update the code for the Lambda function:
- 1.Create a new Zip package with a different name and upload it in the S3 bucket.
- 2.Select the Lambda Function (with the updated S3 Bucket). From the Actions menu, click Edit.
- 3.Enter the updated Name of the Lambda Function.
- 4.Use the Image Configuration field to update an additional configuration parameter.
- 5.Click Submit.
Last modified 2mo ago