add scope to id
This commit is contained in:
@@ -3,7 +3,7 @@ import os
|
||||
from functools import partial
|
||||
from typing import Any
|
||||
|
||||
from aws_lambda_powertools import Logger
|
||||
from aws_lambda_powertools import Logger, Tracer
|
||||
from aws_lambda_powertools.event_handler.api_gateway import (
|
||||
APIGatewayHttpResolver,
|
||||
CORSConfig,
|
||||
@@ -17,6 +17,7 @@ from json_encoder import JSONEncoder
|
||||
from routes import courses, enrollments, orders, users
|
||||
|
||||
logger = Logger(__name__)
|
||||
tracer = Tracer()
|
||||
debug = 'AWS_SAM_LOCAL' in os.environ
|
||||
serializer = partial(json.dumps, separators=(',', ':'), cls=JSONEncoder)
|
||||
cors = CORSConfig(
|
||||
@@ -26,7 +27,10 @@ cors = CORSConfig(
|
||||
allow_credentials=False,
|
||||
)
|
||||
app = APIGatewayHttpResolver(
|
||||
enable_validation=True, cors=cors, debug=debug, serializer=serializer
|
||||
enable_validation=True,
|
||||
cors=cors,
|
||||
debug=debug,
|
||||
serializer=serializer,
|
||||
)
|
||||
app.include_router(courses.router, prefix='/courses')
|
||||
app.include_router(enrollments.router, prefix='/enrollments')
|
||||
@@ -52,5 +56,6 @@ def exc_error(exc: ServiceError):
|
||||
|
||||
|
||||
@logger.inject_lambda_context(correlation_id_path=correlation_paths.API_GATEWAY_HTTP)
|
||||
@tracer.capture_lambda_handler
|
||||
def lambda_handler(event: dict[str, Any], context: LambdaContext) -> dict[str, Any]:
|
||||
return app.resolve(event, context)
|
||||
|
||||
Reference in New Issue
Block a user