Skip to content

feat(typing): add tenant_id property #6985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions aws_lambda_powertools/utilities/typing/lambda_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LambdaContext:
_aws_request_id: str
_log_group_name: str
_log_stream_name: str
_tenant_id: str | None = None
_identity: LambdaCognitoIdentity
_client_context: LambdaClientContext

Expand Down Expand Up @@ -83,6 +84,11 @@ def client_context(self) -> LambdaClientContext:
"""(mobile apps) Client context that's provided to Lambda by the client application."""
return self._client_context

@property
def tenant_id(self) -> str | None:
"""The tenant_id"""
return self._tenant_id

@staticmethod
def get_remaining_time_in_millis() -> int:
"""Returns the number of milliseconds left before the execution times out."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_typing():
context._aws_request_id = "_aws_request_id"
context._log_group_name = "_log_group_name"
context._log_stream_name = "_log_stream_name"
context._tenant_id = "_tenant_id"
identity = LambdaCognitoIdentity()
identity._cognito_identity_id = "_cognito_identity_id"
identity._cognito_identity_pool_id = "_cognito_identity_pool_id"
Expand All @@ -42,6 +43,7 @@ def test_typing():
assert context.aws_request_id == context._aws_request_id
assert context.log_group_name == context._log_group_name
assert context.log_stream_name == context._log_stream_name
assert context.tenant_id == context._tenant_id
assert context.identity == context._identity
assert context.identity.cognito_identity_id == identity._cognito_identity_id
assert context.identity.cognito_identity_pool_id == identity._cognito_identity_pool_id
Expand Down