Skip to content

Instantly share code, notes, and snippets.

@walmsles
Last active January 2, 2023 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walmsles/463d2a953cdfaa351af6dc3c473ad8bb to your computer and use it in GitHub Desktop.
Save walmsles/463d2a953cdfaa351af6dc3c473ad8bb to your computer and use it in GitHub Desktop.
import boto3
import os
from aws_lambda_powertools import Logger, Tracer
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
tracer = Tracer()
logger = Logger()
app = APIGatewayRestResolver()
@app.get("/hello/<name>")
@tracer.capture_method
def get_hello_universe(name):
if name == "michael":
name = "michael, go away!"
return {"message": f"hello {name}"}
# You can continue to use other utilities just as before
@logger.inject_lambda_context()
@tracer.capture_lambda_handler
def lambda_handler(event, context):
return app.resolve(event, context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment