support tenant id in AWS::Lambda::Context#203
Conversation
WalkthroughPropagates tenant ID from the Lambda runtime header Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Changes(1 hunks)lib/AWS/Lambda/Bootstrap.pm(1 hunks)lib/AWS/Lambda/Context.pm(3 hunks)t/10_lambda_next.t(2 hunks)
🔇 Additional comments (7)
Changes (1)
4-4: LGTM!The changelog entry accurately documents the new tenant ID support feature.
lib/AWS/Lambda/Context.pm (4)
17-17: LGTM!Good catch on the typo fix in the error message.
21-21: LGTM!The tenant_id parameter handling is correct and follows the same pattern as other optional fields like trace_id.
Also applies to: 27-27
76-79: LGTM!The tenant_id accessor method follows the established pattern and correctly exposes the tenant ID value.
115-117: LGTM!The documentation appropriately includes the new tenant_id field in the usage example.
t/10_lambda_next.t (2)
23-28: LGTM!The mock response correctly includes the tenant ID header, and the formatting improvements enhance readability.
50-50: LGTM!The test assertion correctly verifies that the tenant ID is properly extracted from the Lambda runtime header and accessible via the context object.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Changes(1 hunks)lib/AWS/Lambda/Bootstrap.pm(3 hunks)
🔇 Additional comments (2)
Changes (1)
4-4: LGTM!The changelog entry is clear, follows the project's format, and correctly references PR #203.
lib/AWS/Lambda/Bootstrap.pm (1)
249-249: LGTM!Good catch on the documentation typos. The corrections improve clarity without affecting functionality.
Also applies to: 264-264
| aws_request_id => $h->{'lambda-runtime-aws-request-id'}, | ||
| invoked_function_arn => $h->{'lambda-runtime-invoked-function-arn'}, | ||
| trace_id => $h->{'lambda-runtime-trace-id'}, | ||
| tenant_id => $h->{'lambda-runtime-aws-tenant-id'}, |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
AWS Lambda Runtime API next invocation lambda-runtime-aws-tenant-id header specification
💡 Result:
Short answer — when tenant isolation is enabled, Lambda includes the tenant identifier on invocation deliveries. The standard Invoke API uses X‑Amzn‑Tenant‑Id and the Runtime API returns tenant info on /runtime/invocation/next in a Lambda‑Runtime‑Aws‑Tenant‑Id response header (see the Runtime API and tenant‑isolation docs). [1][2]
Sources:
- Lambda Runtime API (next invocation /runtime/invocation/next — response headers). [1]
- Lambda tenant isolation / invoking functions with tenant isolation (X‑Amzn‑Tenant‑Id). [2]
🏁 Script executed:
#!/bin/bash
# Check upstream aws-lambda-go PR #604 for tenant header usage
# First try to get PR details via GitHub API
echo "=== Checking aws-lambda-go repository for tenant header usage ==="
curl -s https://api.github.com/repos/aws/aws-lambda-go/pulls/604 | jq -r '.title, .body' 2>/dev/null | head -20
echo -e "\n=== Searching for tenant in aws-lambda-go main branch ==="
# Check the main repository for how they extract tenant ID
curl -s https://raw.githubusercontent.com/aws/aws-lambda-go/main/lambdacontext/lambda_context.go 2>/dev/null | grep -i tenant -A 3 -B 3Repository: shogo82148/p5-aws-lambda
Length of output: 596
The header name is correct but should match AWS documentation casing: use Lambda-Runtime-Aws-Tenant-Id instead of lambda-runtime-aws-tenant-id.
According to AWS Lambda Runtime API documentation, the /runtime/invocation/next endpoint returns tenant information in a response header named Lambda-Runtime-Aws-Tenant-Id (with PascalCase-with-hyphens casing). While HTTP header names are case-insensitive in transmission, the code currently uses all lowercase lambda-runtime-aws-tenant-id. This is inconsistent with AWS's official specification format and the standard naming convention used elsewhere in the codebase.
Note: The previous review confusion about X-Amzn-Tenant-Id refers to the standard Invoke API (used when calling Lambda), whereas this code correctly uses the Runtime API header for the runtime environment's /next endpoint response.
🤖 Prompt for AI Agents
In lib/AWS/Lambda/Bootstrap.pm around line 151, the header key is set to
all-lowercase 'lambda-runtime-aws-tenant-id'; update it to match AWS
documentation casing 'Lambda-Runtime-Aws-Tenant-Id' so the code uses the
documented header name while preserving case-insensitive lookup semantics and
keeping consistency with other code that uses PascalCase-with-hyphens for
runtime headers.
Changelog diff is: diff --git a/Changes b/Changes index 49a76a3..db60fb4 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Perl extension aws-lambda {{$NEXT}} + +0.7.0 2025-12-13T04:33:18Z - Support tenant id in AWS::Lambda::Context #203 - Add support for AWS_LAMBDA_MAX_CONCURRENCY #204 - Mark Amazon Linux 2 (AL2) based layers as no longer maintained #206
ref. aws/aws-lambda-go#604
https://aws.amazon.com/blogs/compute/building-multi-tenant-saas-applications-with-aws-lambdas-new-tenant-isolation-mode/
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.