您的第一个 Lambda 函数
使用 AWS 控制台编写、配置并部署一个简单的“Hello World”Lambda 函数,亲身体验该平台
您的第一个 Lambda 函数 是 CoddyKit 上的免费 Serverless AWS Lambda Development 课时。 这是第 3 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Serverless AWS Lambda Development 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Serverless AWS Lambda Development 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Your First Lambda Function
Time to build! You will create and deploy your first Hello World Lambda right in the AWS console — your practical step into serverless.
Find Lambda in AWS Console
Log into the AWS console, search "Lambda" in the top bar, and select it to open the Lambda dashboard where all your functions live.
Start a New Lambda Function
On the dashboard, click Create function and choose "Author from scratch" to define a brand-new serverless function.
Name Your Function & Runtime
Set the basics: a unique Function name and a Runtime — the language your code runs in. We will use Python 3.9 here.
Lambda's Permissions: Execution Role
Your function needs an execution role (an IAM role) for permissions. Pick "Create a new role with basic Lambda permissions" to allow CloudWatch logs.
Code Your 'Hello World'
The console opens a code editor — replace the default with this simple Python Hello World handler.
import json
def lambda_handler(event, context):
# Log the event for debugging purposes
print(f"Received event: {event}")
# Return a simple greeting
return {
'statusCode': 200,
'body': json.dumps('Hello from your first Lambda!')
}Save & Deploy Your Function
After editing, click Deploy to save your changes and make the new version live. Skip this and the Lambda service keeps the old code.
Test Your Lambda Function
Open the Test tab and configure a test event — the hello-world template works — name it, then click Test to invoke your function and see results.
Check Logs for Output
After a test, results appear inline. For full output, including your print() statements, open CloudWatch Logs where Lambda sends its runtime logs.
Quick Check: Lambda Deployment
You've just deployed your first Lambda! Let's check your understanding of the essential steps.
Recap: Your First Lambda
Congrats! You created, configured, coded, deployed, and tested your first Lambda function — the foundational skill for serverless apps.
常见问题解答
「您的第一个 Lambda 函数」课时是免费的吗?
是的 — 「您的第一个 Lambda 函数」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Serverless AWS Lambda Development 课程的其余内容,请升级到 CoddyKit PRO。 Serverless AWS Lambda Development 课程共包含 4 节课。
「您的第一个 Lambda 函数」这节课中我会学到什么?
使用 AWS 控制台编写、配置并部署一个简单的“Hello World”Lambda 函数,亲身体验该平台 你通过在浏览器中直接运行的动手代码来练习 Serverless AWS Lambda Development,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Serverless AWS Lambda Development 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Serverless AWS Lambda Development 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 3 节课,共 4 节。
「您的第一个 Lambda 函数」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Serverless AWS Lambda Development 课中编写并运行代码吗?
能。每节 Serverless AWS Lambda Development 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- 什么是无服务器计算
- AWS Lambda 入门
- 您的第一个 Lambda 函数
- 无服务器定价与免费层级