Skip to content

Commit 4f13210

Browse files
Merge branch 'main' into dependabot/cargo/axum-extra-0.12.5
2 parents 4d156f5 + 217ecaf commit 4f13210

20 files changed

Lines changed: 436 additions & 25 deletions

File tree

.github/workflows/release-plz.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-plz-release:
10+
name: Release-plz release
11+
runs-on: ubuntu-latest
12+
if: ${{ github.repository_owner == 'aws' }}
13+
permissions:
14+
contents: write
15+
id-token: write
16+
steps:
17+
- &checkout
18+
name: Checkout repository
19+
uses: actions/checkout@v5
20+
with:
21+
fetch-depth: 0
22+
- &install-rust
23+
name: Install Rust toolchain
24+
uses: dtolnay/rust-toolchain@stable
25+
- name: Authenticate to crates.io
26+
uses: rust-lang/crates-io-auth-action@v1
27+
id: auth
28+
- name: Run release-plz
29+
uses: release-plz/action@v0.5
30+
with:
31+
command: release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
34+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
35+
36+
release-plz-pr:
37+
name: Release-plz PR
38+
runs-on: ubuntu-latest
39+
if: ${{ github.repository_owner == 'aws' }}
40+
permissions:
41+
pull-requests: write
42+
contents: write
43+
concurrency:
44+
group: release-plz-${{ github.ref }}
45+
cancel-in-progress: false
46+
steps:
47+
- *checkout
48+
- *install-rust
49+
- name: Run release-plz
50+
uses: release-plz/action@v0.5
51+
with:
52+
command: release-pr
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}

.github/workflows/run-integration-test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ jobs:
4747
echo "STACK_NAME=$stackName" >> "$GITHUB_OUTPUT"
4848
echo "Stack name = $stackName"
4949
sam deploy --stack-name "${stackName}" --parameter-overrides "ParameterKey=SecretToken,ParameterValue=${{ secrets.SECRET_TOKEN }}" "ParameterKey=LambdaRole,ParameterValue=${{ secrets.AWS_LAMBDA_ROLE }}" --no-confirm-changeset --no-progressbar > disable_output
50-
TEST_ENDPOINT=$(sam list stack-outputs --stack-name "${stackName}" --output json | jq -r '.[] | .OutputValue')
50+
TEST_ENDPOINT=$(sam list stack-outputs --stack-name "${stackName}" --output json | jq -r '.[] | select(.OutputKey=="HelloApiEndpoint") | .OutputValue')
51+
TENANT_ID_TEST_FUNCTION=$(sam list stack-outputs --stack-name "${stackName}" --output json | jq -r '.[] | select(.OutputKey=="TenantIdTestFunction") | .OutputValue')
5152
echo "TEST_ENDPOINT=$TEST_ENDPOINT" >> "$GITHUB_OUTPUT"
53+
echo "TENANT_ID_TEST_FUNCTION=$TENANT_ID_TEST_FUNCTION" >> "$GITHUB_OUTPUT"
5254
- name: run test
5355
env:
5456
SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }}
5557
TEST_ENDPOINT: ${{ steps.deploy_stack.outputs.TEST_ENDPOINT }}
58+
TENANT_ID_TEST_FUNCTION: ${{ steps.deploy_stack.outputs.TENANT_ID_TEST_FUNCTION }}
5659
run: cd lambda-integration-tests && cargo test
5760
- name: cleanup
5861
if: always() && steps.deploy_stack.outputs.STACK_NAME
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "basic-tenant-id"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
lambda_runtime = { path = "../../lambda-runtime" }
8+
serde_json = "1.0"
9+
tokio = { version = "1", features = ["macros"] }
10+
tracing = { version = "0.1", features = ["log"] }
11+
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }

examples/basic-tenant-id/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Basic Tenant ID Example
2+
3+
This example demonstrates how to access and use tenant ID information in a Lambda function.
4+
5+
## Key Features
6+
7+
- Extracts tenant ID from Lambda runtime headers
8+
- Includes tenant ID in tracing logs
9+
- Returns tenant ID in the response
10+
- Handles cases where tenant ID is not provided
11+
12+
## Usage
13+
14+
The tenant ID is automatically extracted from the `lambda-runtime-aws-tenant-id` header and made available in the Lambda context.
15+
16+
```rust
17+
async fn function_handler(event: LambdaEvent<Value>) -> Result<Value, Error> {
18+
let (event, context) = event.into_parts();
19+
20+
// Access tenant ID from context
21+
match &context.tenant_id {
22+
Some(tenant_id) => println!("Processing for tenant: {}", tenant_id),
23+
None => println!("No tenant ID provided"),
24+
}
25+
26+
// ... rest of function logic
27+
}
28+
```
29+
30+
## Testing
31+
32+
You can test this function locally using cargo lambda:
33+
34+
```bash
35+
cargo lambda invoke --data-ascii '{"test": "data"}'
36+
```
37+
38+
The tenant ID will be None when testing locally unless you set up a mock runtime environment with the appropriate headers.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use lambda_runtime::{service_fn, Error, LambdaEvent};
2+
use serde_json::{json, Value};
3+
4+
async fn function_handler(event: LambdaEvent<Value>) -> Result<Value, Error> {
5+
let (event, context) = event.into_parts();
6+
7+
// Access tenant ID from context
8+
let tenant_info = match &context.tenant_id {
9+
Some(tenant_id) => format!("Processing request for tenant: {}", tenant_id),
10+
None => "No tenant ID provided".to_string(),
11+
};
12+
13+
tracing::info!("Request ID: {}", context.request_id);
14+
tracing::info!("Tenant info: {}", tenant_info);
15+
16+
// Include tenant ID in response
17+
let response = json!({
18+
"message": "Hello from Lambda!",
19+
"request_id": context.request_id,
20+
"tenant_id": context.tenant_id,
21+
"input": event
22+
});
23+
24+
Ok(response)
25+
}
26+
27+
#[tokio::main]
28+
async fn main() -> Result<(), Error> {
29+
tracing_subscriber::fmt()
30+
.with_max_level(tracing::Level::INFO)
31+
.with_target(false)
32+
.without_time()
33+
.init();
34+
35+
lambda_runtime::run(service_fn(function_handler)).await
36+
}

lambda-events/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws_lambda_events"
3-
version = "1.0.2"
3+
version = "1.0.3"
44
rust-version = "1.84.0"
55
description = "AWS Lambda event definitions"
66
authors = [
@@ -131,4 +131,4 @@ catch-all-fields = []
131131
all-features = true
132132

133133
[dev-dependencies]
134-
lambda_runtime = { path = "../lambda-runtime" }
134+
lambda_runtime = { version = "1.1.0-rc1", path = "../lambda-runtime" }

lambda-extension/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda-extension"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
edition = "2021"
55
rust-version = "1.84.0"
66
authors = [
@@ -25,7 +25,7 @@ http = { workspace = true }
2525
http-body-util = { workspace = true }
2626
hyper = { workspace = true, features = ["http1", "client", "server"] }
2727
hyper-util = { workspace = true }
28-
lambda_runtime_api_client = { version = "1.0", path = "../lambda-runtime-api-client" }
28+
lambda_runtime_api_client = { version = "1.0.2", path = "../lambda-runtime-api-client" }
2929
serde = { version = "1", features = ["derive"] }
3030
serde_json = "^1"
3131
tokio = { version = "1.0", features = [

lambda-http/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_http"
3-
version = "1.0.2"
3+
version = "1.1.0-rc1"
44
authors = [
55
"David Calavera <dcalaver@amazon.com>",
66
"Harold Sun <sunhua@amazon.com>",
@@ -39,7 +39,7 @@ http = { workspace = true }
3939
http-body = { workspace = true }
4040
http-body-util = { workspace = true }
4141
hyper = { workspace = true }
42-
lambda_runtime = { version = "1.0", path = "../lambda-runtime" }
42+
lambda_runtime = { version = "1.1.0-rc1", path = "../lambda-runtime" }
4343
mime = "0.3"
4444
percent-encoding = "2.2"
4545
pin-project-lite = { workspace = true }
@@ -57,8 +57,10 @@ features = ["alb", "apigw"]
5757

5858
[dev-dependencies]
5959
axum-core = "0.5.4"
60+
6061
axum-extra = { version = "0.12.5", features = ["query"] }
61-
lambda_runtime_api_client = { version = "1.0", path = "../lambda-runtime-api-client" }
62+
lambda_runtime_api_client = { version = "1.0.2", path = "../lambda-runtime-api-client" }
63+
6264
log = "^0.4"
6365
maplit = "1.0"
6466
tokio = { version = "1.0", features = ["macros"] }

lambda-integration-tests/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ aws_lambda_events = { path = "../lambda-events" }
1717
serde_json = "1.0.121"
1818
tokio = { version = "1", features = ["full"] }
1919
serde = { version = "1.0.204", features = ["derive"] }
20+
tracing = "0.1"
2021

2122
[dev-dependencies]
2223
reqwest = { version = "0.13.1", features = ["blocking"] }
@@ -31,3 +32,7 @@ path = "src/helloworld.rs"
3132
[[bin]]
3233
name = "authorizer"
3334
path = "src/authorizer.rs"
35+
36+
[[bin]]
37+
name = "tenant-id-test"
38+
path = "src/tenant_id_test.rs"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use lambda_runtime::{service_fn, Error, LambdaEvent};
2+
use serde_json::{json, Value};
3+
4+
async fn function_handler(event: LambdaEvent<Value>) -> Result<Value, Error> {
5+
let (event, context) = event.into_parts();
6+
7+
tracing::info!("Processing request with tenant ID: {:?}", context.tenant_id);
8+
9+
let response = json!({
10+
"statusCode": 200,
11+
"body": json!({
12+
"message": "Tenant ID test successful",
13+
"request_id": context.request_id,
14+
"tenant_id": context.tenant_id,
15+
"input": event
16+
}).to_string()
17+
});
18+
19+
Ok(response)
20+
}
21+
22+
#[tokio::main]
23+
async fn main() -> Result<(), Error> {
24+
lambda_runtime::tracing::init_default_subscriber();
25+
lambda_runtime::run(service_fn(function_handler)).await
26+
}

0 commit comments

Comments
 (0)