코드 예시 — 이벤트 트리거 함수
# handler.py — API Gateway 이벤트로 트리거되는 서버리스 함수
def lambda_handler(event, context):
# 요청마다 새 인스턴스일 수도, 재사용된 인스턴스일 수도 있음
name = event["queryStringParameters"].get("name", "world")
return {
"statusCode": 200,
"body": f"Hello, {name}!"
}
# serverless.yml — 이벤트 트리거 정의
functions:
hello:
handler: handler.lambda_handler
events:
- httpApi:
path: /hello
method: get