- Building Serverless Python Web Services with Zappa
- Abdulwahid Abdulhaque Barguzar
- 472字
- 2021-07-16 18:16:07
How AWS Lambda works
You need to write a function, which will be executed by AWS Lambda on your behalf.
AWS Lambda is implemented on a container-based model that supports a runtime environment and executes the code as per the Lambda function configuration. When the Lambda function is invoked, it launches the container (an execution environment) based on the AWS Lambda configuration and enables the basic runtime environment, which is required to execute the code.
Let's start with some practical work:
- To create a Lambda function, you must have an AWS account. If you don't have an AWS account, then you need to sign up on AWS (https://aws.amazon.com/) by providing some basic contact and payment information, as it's essential information required by Amazon.
- Go to the Lambda home page (https://console.aws.amazon.com/lambda/home). Click on the Create a function button. This will redirect you to the Create function page, which is described in the next step. Take a look at the following screenshot:

- AWS provides three different options to create a Lambda function, such as Author from scratch, Blueprints, and Serverless Application Repository. We will be using the Blueprint option, which has some built-in Lambda functions. We can choose these blueprints based on our requirements from the search bar, where you can filter by tag and attributes or search by keywords:

- Let's choose a hello-world-python blueprint. Once we choose the blueprint, we need to set up the basic information about the Lambda function. This information includes the Lambda function's Name and Role, as shown in the following screenshot:

- Here, Name will be a unique identification for your Lambda function and Role defines the permissions of your Lambda function.
There are three options available for creating a role:
- Choose an existing role
- Create new role from template(s)
- Create a custom role
Let's look at them in more detail:- Choose an existing role: This allows you to select the previously created role.
- Create new role from template(s): Here, you need to define a role name. AWS Lambda provides ready-made built-in role policy templates that have pre-configured permissions. These are based on other AWS services-related permissions required by the AWS Lambda function. On any role selection, Lambda will automatically add the logging permission to CloudWatch (AWS logging service), as this is the basic permission required by Lambda.
- Create a custom role: AWS provides an additional privilege to create a customized role to access AWS Lambda. Here, you can define the role based on your requirement.
- Let's create the HelloWorld Lambda function with some role. Here, I chose the S3 object read-only permission policy template.
- The following screenshot describes the newly created HelloWorld Lambda function:

HelloWorld Lambda function
The Lambda function includes three sections:
- Configuration
- Triggers
- Monitoring
Let's look at detailed information about the configuration and monitoring. We will have a separate section for triggers.
推薦閱讀
- 微商之道
- Building E-commerce Sites with VirtueMart Cookbook
- 智能網聯汽車V2X與智能網聯設施I2X
- Django 2 by Example
- Web Application Development with R Using Shiny
- Windows Server 2003 Active Directory Design and Implementation: Creating, Migrating, and Merging Networks
- Building RESTful Web Services with Spring 5(Second Edition)
- Mastering JavaFX 10
- 網絡環境中基于用戶視角的信息質量評價研究
- 夢工廠之材質N次方:Maya材質手冊
- 網絡設計與應用(第2版)
- TD-LTE無線網絡規劃與設計
- 5G時代的大數據技術架構和關鍵技術詳解
- 云計算技術與標準化
- 新媒體交互藝術