Feature request: Add tentant_id field to Context object and propagate to logger
Use case
AWS Lambda RIC added a new field called tenantId and we need to add this field to the context. This must be a optional String and must check if tenantId is present in the context.
I tested with some functions and it's present while in others it's not.
Solution/User Experience
Add this field to the Context object and log it when injecting Lambda context.
Alternative solutions
Acknowledgment
- [x] This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- [x] Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Thanks, sounds good.
I'll put this on hold for now, and we'll work on it next month.
Need to check if the new field is present in the context already or not.
Verified that the field is present in the runtime, below an example:
{
callbackWaitsForEmptyEventLoop: [Getter/Setter],
succeed: [Function (anonymous)],
fail: [Function (anonymous)],
done: [Function (anonymous)],
functionVersion: '$LATEST',
functionName: 'TenantFn',
memoryLimitInMB: '128',
logGroupName: '/aws/lambda/TenantFn',
logStreamName: '2025/07/15/TenantFn[$LATEST]5fe3c6d22b44430e91840af6f6304cd3',
clientContext: undefined,
identity: undefined,
invokedFunctionArn: 'arn:aws:lambda:eu-west-1:536254204126:function:TenantFn',
awsRequestId: 'cc3f97fc-219b-4cbf-86f0-d75763154364',
tenantId: undefined,
getRemainingTimeInMillis: [Function: getRemainingTimeInMillis]
}
Opened a PR to the @types/aws-lambda repo to add this type for all customers: DefinitelyTyped/DefinitelyTyped#73265
PR was merged and the type including the new key has been published 2 days ago under version 8.10.152 (see here).
Since we're not adding the key to the logger when appending the context, I'm closing the issue as completed.
[!warning] This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either reopen the issue, or open a new issue referencing this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.