Unverified Commit 99e1e208 authored by Fahad Zubair's avatar Fahad Zubair Committed by GitHub
Browse files

Add `aws-lambda` as a feature to generated server SDK (#3648)

## Motivation and Context
The generated SDK conditionally re-exports `routing::LambdaHandler`
under the feature flag aws-lambda, but the `Cargo.toml` does not define
such a feature.

## Description
Closes: https://github.com/smithy-lang/smithy-rs/issues/3643



## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates

---------

Co-authored-by: default avatarFahad Zubair <fahadzub@amazon.com>
Co-authored-by: default avatardavid-perez <d@vidp.dev>
parent 6e0f418c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -10,3 +10,8 @@
# references = ["smithy-rs#920"]
# meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"}
# author = "rcoh"
[[smithy-rs]]
message = "A feature, `aws-lambda`, has been added to generated SDKs to re-export types required for Lambda deployment."
references = ["smithy-rs#3643"]
meta = { "breaking" = false, "bug" = true, "tada" = false, "target" = "server" }
author = "drganjoo"
+8 −0
Original line number Diff line number Diff line
@@ -48,6 +48,14 @@ class ServerRequiredCustomizations : ServerCodegenDecorator {
            ),
        )

        rustCrate.mergeFeature(
            Feature(
                "aws-lambda",
                true,
                listOf("aws-smithy-http-server/aws-lambda"),
            ),
        )

        rustCrate.withModule(ServerRustModule.Types) {
            pubUseSmithyPrimitives(codegenContext, codegenContext.model, rustCrate)(this)
            rustTemplate(
+5 −0
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@ class ServerRuntimeTypesReExportsGenerator(
            }
            pub mod request {
                pub use #{SmithyHttpServer}::request::FromParts;

                ##[cfg(feature = "aws-lambda")]
                pub mod lambda {
                    pub use #{SmithyHttpServer}::request::lambda::Context;
                }
            }
            pub mod response {
                pub use #{SmithyHttpServer}::response::IntoResponse;
+2 −2
Original line number Diff line number Diff line
@@ -19,6 +19,6 @@ tracing = "0.1"
lambda_http = "0.8.0"

# Local paths
aws-smithy-http-server = { path = "../../rust-runtime/aws-smithy-http-server", features = ["aws-lambda"] }
pokemon-service-server-sdk = { path = "../pokemon-service-server-sdk/" }
aws-smithy-http-server = { path = "../../rust-runtime/aws-smithy-http-server" }
pokemon-service-server-sdk = { path = "../pokemon-service-server-sdk/", features = ["aws-lambda"] }
pokemon-service-common = { path = "../pokemon-service-common/" }
+2 −1
Original line number Diff line number Diff line
@@ -5,13 +5,14 @@

use std::sync::Arc;

use aws_smithy_http_server::{request::lambda::Context, Extension};
use aws_smithy_http_server::Extension;

use pokemon_service_common::State;
use pokemon_service_server_sdk::{
    error::{GetStorageError, StorageAccessNotAuthorized},
    input::GetStorageInput,
    output::GetStorageOutput,
    server::request::lambda::Context,
};

/// Retrieves the user's storage and logs the lambda request ID.
Loading