Seth Geoghegan
02/25/2022, 9:27 PMRoss Coundon
02/25/2022, 9:33 PMRoss Coundon
02/25/2022, 9:33 PMSeth Geoghegan
02/25/2022, 9:39 PMFrank
Frank
Seth Geoghegan
02/25/2022, 10:19 PMSeth Geoghegan
02/25/2022, 10:20 PMSeth Geoghegan
02/25/2022, 10:21 PMSeth Geoghegan
02/25/2022, 10:23 PMFrank
Frank
Apparently it has features that extract data from the context, which I was not sending to the handler in my SST console requestBy
context, do you mean you needed to access data from the 2nd argument of the Lambda handler, like log group arn, memory setting, etc? ie.
handler(event, context) { ... }Seth Geoghegan
02/27/2022, 4:32 PMSeth Geoghegan
02/27/2022, 4:43 PMSeth Geoghegan
02/28/2022, 5:06 PMFrank
InvocationType being Event.Frank
Frank
Seth Geoghegan
02/28/2022, 11:00 PM@logger.inject_lambda_context
def handler(event, context):
// do stuff here
and the module will log elements from the context to cloudwatch. The fields it's expecting are documented here.
This isn't blocking my work, it's just a functionality I was testing out. When it didn't work, I simply removed the @logger.inject_lambda_context decorator, but it made me wonder how SST console was invoking the APIFrank
Frank
function_name, other context names don’t match up.Frank
context.Frank
@logger.inject_lambda_context decorator enabled?Frank
Seth Geoghegan
03/01/2022, 12:23 AMSeth Geoghegan
03/01/2022, 12:37 AM==========================
Starting Live Lambda Dev
==========================
SST Console: <https://console.serverless-stack.com/kas/sgeoghegan/local>
Debug session started. Listening for requests...
eeacd8f6-1ac8-4bf6-9aa1-7685e6fd38ad REQUEST sgeoghegan-kas-kas-apiLambdaGET2D5CB7A7-spZCO4MI9530 [functions/index.handler] invoked
Traceback (most recent call last):
File "/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@serverless-stack/core/src/runtime/shells/bootstrap.py", line 77, in <module>
result = handler(event, context)
File "/Users/sgeoghegan/dev/knock-attribution-service/src/.venv/lib/python3.9/site-packages/aws_lambda_powertools/logging/logger.py", line 339, in decorate
lambda_context = build_lambda_context_model(context)
File "/Users/sgeoghegan/dev/knock-attribution-service/src/.venv/lib/python3.9/site-packages/aws_lambda_powertools/logging/lambda_context.py", line 52, in build_lambda_context_model
"function_name": context.function_name,
AttributeError: 'Context' object has no attribute 'function_name'
eeacd8f6-1ac8-4bf6-9aa1-7685e6fd38ad ERROR AttributeError: 'Context' object has no attribute 'function_name'Seth Geoghegan
03/01/2022, 12:37 AMfrom aws_lambda_powertools.utilities.typing import LambdaContext
from aws_lambda_powertools.logging.logger import Logger
logger = Logger(service="payment")
@logger.inject_lambda_context
def handler(event, context: LambdaContext):
return {
"statusCode": 200,
"headers": {"Content-Type": "text/plain"},
"body": "You Lambda is live!"
}Frank
function_name and some other missing contexts.Seth Geoghegan
03/01/2022, 3:38 PM