From 56f1167a97d65a8fd912a587a401c6c0fafaea16 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sun, 28 Sep 2025 17:46:05 +0200 Subject: [PATCH 1/3] rename example APIGateway to APIGatewayV2 (fix 572) --- Examples/APIGatewayV1/README.md | 4 ++-- .../.gitignore | 0 .../Package.swift | 0 .../README.md | 4 ++-- .../Sources/APIGatewayLambda/main.swift | 0 .../Sources/AuthorizerLambda/main.swift | 0 .../template.yaml | 0 Examples/{APIGateway => APIGatewayV2}/.gitignore | 0 Examples/{APIGateway => APIGatewayV2}/Package.swift | 0 Examples/{APIGateway => APIGatewayV2}/README.md | 7 +++++-- Examples/{APIGateway => APIGatewayV2}/Sources/main.swift | 0 Examples/{APIGateway => APIGatewayV2}/template.yaml | 0 Examples/README.md | 6 +++--- 13 files changed, 12 insertions(+), 9 deletions(-) rename Examples/{APIGateway+LambdaAuthorizer => APIGatewayV2+LambdaAuthorizer}/.gitignore (100%) rename Examples/{APIGateway+LambdaAuthorizer => APIGatewayV2+LambdaAuthorizer}/Package.swift (100%) rename Examples/{APIGateway+LambdaAuthorizer => APIGatewayV2+LambdaAuthorizer}/README.md (97%) rename Examples/{APIGateway+LambdaAuthorizer => APIGatewayV2+LambdaAuthorizer}/Sources/APIGatewayLambda/main.swift (100%) rename Examples/{APIGateway+LambdaAuthorizer => APIGatewayV2+LambdaAuthorizer}/Sources/AuthorizerLambda/main.swift (100%) rename Examples/{APIGateway+LambdaAuthorizer => APIGatewayV2+LambdaAuthorizer}/template.yaml (100%) rename Examples/{APIGateway => APIGatewayV2}/.gitignore (100%) rename Examples/{APIGateway => APIGatewayV2}/Package.swift (100%) rename Examples/{APIGateway => APIGatewayV2}/README.md (93%) rename Examples/{APIGateway => APIGatewayV2}/Sources/main.swift (100%) rename Examples/{APIGateway => APIGatewayV2}/template.yaml (100%) diff --git a/Examples/APIGatewayV1/README.md b/Examples/APIGatewayV1/README.md index c34b6032..110efc2c 100644 --- a/Examples/APIGatewayV1/README.md +++ b/Examples/APIGatewayV1/README.md @@ -1,9 +1,9 @@ -# API Gateway +# REST API Gateway This is a simple example of an AWS Lambda function invoked through an Amazon API Gateway V1. > [!NOTE] -> This example uses the API Gateway V1 `Api` endpoint type, whereas the [API Gateway V2](https://github.com/swift-server/swift-aws-lambda-runtime/tree/main/Examples/APIGateway) example uses the `HttpApi` endpoint type. For more information, see [Choose between REST AIs and HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html). +> This example uses the API Gateway V1 `Rest Api` endpoint type, whereas the [API Gateway V2](https://github.com/swift-server/swift-aws-lambda-runtime/tree/main/Examples/APIGateway) example uses the `HttpApi` endpoint type. For more information, see [Choose between REST APIs and HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html). ## Code diff --git a/Examples/APIGateway+LambdaAuthorizer/.gitignore b/Examples/APIGatewayV2+LambdaAuthorizer/.gitignore similarity index 100% rename from Examples/APIGateway+LambdaAuthorizer/.gitignore rename to Examples/APIGatewayV2+LambdaAuthorizer/.gitignore diff --git a/Examples/APIGateway+LambdaAuthorizer/Package.swift b/Examples/APIGatewayV2+LambdaAuthorizer/Package.swift similarity index 100% rename from Examples/APIGateway+LambdaAuthorizer/Package.swift rename to Examples/APIGatewayV2+LambdaAuthorizer/Package.swift diff --git a/Examples/APIGateway+LambdaAuthorizer/README.md b/Examples/APIGatewayV2+LambdaAuthorizer/README.md similarity index 97% rename from Examples/APIGateway+LambdaAuthorizer/README.md rename to Examples/APIGatewayV2+LambdaAuthorizer/README.md index ea15f9bd..35567333 100644 --- a/Examples/APIGateway+LambdaAuthorizer/README.md +++ b/Examples/APIGatewayV2+LambdaAuthorizer/README.md @@ -1,6 +1,6 @@ -# Lambda Authorizer with API Gateway +# Lambda Authorizer with HTTPS API Gateway -This is an example of a Lambda Authorizer function. There are two Lambda functions in this example. The first one is the authorizer function. The second one is the business function. The business function is exposed through a REST API using the API Gateway. The API Gateway is configured to use the authorizer function to implement a custom logic to authorize the requests. +This is an example of a Lambda Authorizer function. There are two Lambda functions in this example. The first one is the authorizer function. The second one is the business function. The business function is exposed through a REST API using the HTTPS API Gateway. The API Gateway is configured to use the authorizer function to implement a custom logic to authorize the requests. >[!NOTE] > If your application is protected by JWT tokens, it's recommended to use [the native JWT authorizer provided by the API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html). The Lambda authorizer is useful when you need to implement a custom authorization logic. See the [OAuth 2.0/JWT authorizer example for AWS SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-controlling-access-to-apis-oauth2-authorizer.html) to learn how to use the native JWT authorizer with SAM. diff --git a/Examples/APIGateway+LambdaAuthorizer/Sources/APIGatewayLambda/main.swift b/Examples/APIGatewayV2+LambdaAuthorizer/Sources/APIGatewayLambda/main.swift similarity index 100% rename from Examples/APIGateway+LambdaAuthorizer/Sources/APIGatewayLambda/main.swift rename to Examples/APIGatewayV2+LambdaAuthorizer/Sources/APIGatewayLambda/main.swift diff --git a/Examples/APIGateway+LambdaAuthorizer/Sources/AuthorizerLambda/main.swift b/Examples/APIGatewayV2+LambdaAuthorizer/Sources/AuthorizerLambda/main.swift similarity index 100% rename from Examples/APIGateway+LambdaAuthorizer/Sources/AuthorizerLambda/main.swift rename to Examples/APIGatewayV2+LambdaAuthorizer/Sources/AuthorizerLambda/main.swift diff --git a/Examples/APIGateway+LambdaAuthorizer/template.yaml b/Examples/APIGatewayV2+LambdaAuthorizer/template.yaml similarity index 100% rename from Examples/APIGateway+LambdaAuthorizer/template.yaml rename to Examples/APIGatewayV2+LambdaAuthorizer/template.yaml diff --git a/Examples/APIGateway/.gitignore b/Examples/APIGatewayV2/.gitignore similarity index 100% rename from Examples/APIGateway/.gitignore rename to Examples/APIGatewayV2/.gitignore diff --git a/Examples/APIGateway/Package.swift b/Examples/APIGatewayV2/Package.swift similarity index 100% rename from Examples/APIGateway/Package.swift rename to Examples/APIGatewayV2/Package.swift diff --git a/Examples/APIGateway/README.md b/Examples/APIGatewayV2/README.md similarity index 93% rename from Examples/APIGateway/README.md rename to Examples/APIGatewayV2/README.md index c2fcb765..e7f41c4a 100644 --- a/Examples/APIGateway/README.md +++ b/Examples/APIGatewayV2/README.md @@ -1,6 +1,9 @@ -# API Gateway +# HTTPS API Gateway -This is a simple example of an AWS Lambda function invoked through an Amazon API Gateway. +This is a simple example of an AWS Lambda function invoked through an Amazon HTTPS API Gateway. + +> [!NOTE] +> This example uses the API Gateway V2 `Http Api` endpoint type, whereas the [API Gateway V1](https://github.com/swift-server/swift-aws-lambda-runtime/tree/main/Examples/APIGatewayV1) example uses the `Rest Api` endpoint type. For more information, see [Choose between REST APIs and HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html). ## Code diff --git a/Examples/APIGateway/Sources/main.swift b/Examples/APIGatewayV2/Sources/main.swift similarity index 100% rename from Examples/APIGateway/Sources/main.swift rename to Examples/APIGatewayV2/Sources/main.swift diff --git a/Examples/APIGateway/template.yaml b/Examples/APIGatewayV2/template.yaml similarity index 100% rename from Examples/APIGateway/template.yaml rename to Examples/APIGatewayV2/template.yaml diff --git a/Examples/README.md b/Examples/README.md index e2ee1197..c5f6d38c 100644 --- a/Examples/README.md +++ b/Examples/README.md @@ -16,11 +16,11 @@ This directory contains example code for Lambda functions. ## Examples -- **[API GatewayV1](APIGatewayV1/README.md)**: an REST API with [Amazon API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html) and a Lambda function as backend (requires [AWS SAM](https://aws.amazon.com/serverless/sam/)). +- **[API Gateway V1](APIGatewayV1/README.md)**: an REST API with [Amazon API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html) and a Lambda function as backend (requires [AWS SAM](https://aws.amazon.com/serverless/sam/)). -- **[API Gateway](APIGateway/README.md)**: an HTTPS REST API with [Amazon API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html) and a Lambda function as backend (requires [AWS SAM](https://aws.amazon.com/serverless/sam/)). +- **[API Gateway V2](APIGatewayV2/README.md)**: an HTTPS API with [Amazon API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html) and a Lambda function as backend (requires [AWS SAM](https://aws.amazon.com/serverless/sam/)). -- **[API Gateway with Lambda Authorizer](APIGateway+LambdaAuthorizer/README.md)**: an HTTPS REST API with [Amazon API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html) protected by a Lambda authorizer (requires [AWS SAM](https://aws.amazon.com/serverless/sam/)). +- **[API Gateway V2 with Lambda Authorizer](APIGatewayV2+LambdaAuthorizer/README.md)**: an HTTPS API with [Amazon API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html) protected by a Lambda authorizer (requires [AWS SAM](https://aws.amazon.com/serverless/sam/)). - **[BackgroundTasks](BackgroundTasks/README.md)**: a Lambda function that continues to run background tasks after having sent the response (requires [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)). From 6af6e6602acb3a5a15664a94fa4033c7f14ed6c7 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sun, 28 Sep 2025 17:46:23 +0200 Subject: [PATCH 2/3] [ci] update list of example projects to test --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index eced9608..be5613de 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -39,7 +39,7 @@ jobs: # We pass the list of examples here, but we can't pass an array as argument # Instead, we pass a String with a valid JSON array. # The workaround is mentioned here https://github.com/orgs/community/discussions/11692 - examples: "[ 'APIGateway', 'APIGateway+LambdaAuthorizer', 'BackgroundTasks', 'HelloJSON', 'HelloWorld', 'HelloWorldNoTraits', 'HummingbirdLambda', 'ResourcesPackaging', 'S3EventNotifier', 'S3_AWSSDK', 'S3_Soto', 'Streaming', 'Streaming+Codable', 'ServiceLifecycle+Postgres', 'Testing', 'Tutorial' ]" + examples: "[ 'APIGatewayV1', 'APIGatewayV2', 'APIGatewayV2+LambdaAuthorizer', 'BackgroundTasks', 'HelloJSON', 'HelloWorld', 'HelloWorldNoTraits', 'HummingbirdLambda', 'ResourcesPackaging', 'S3EventNotifier', 'S3_AWSSDK', 'S3_Soto', 'Streaming', 'Streaming+Codable', 'ServiceLifecycle+Postgres', 'Testing', 'Tutorial' ]" archive_plugin_examples: "[ 'HelloWorld', 'ResourcesPackaging' ]" archive_plugin_enabled: true From fd16d09f59a689b067e1308057addd52292cf221 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sun, 28 Sep 2025 17:54:02 +0200 Subject: [PATCH 3/3] adjust check link to foundation test to new directory name --- .github/workflows/scripts/check-link-foundation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/check-link-foundation.sh b/.github/workflows/scripts/check-link-foundation.sh index be84116c..ccef6ee7 100755 --- a/.github/workflows/scripts/check-link-foundation.sh +++ b/.github/workflows/scripts/check-link-foundation.sh @@ -17,7 +17,7 @@ log() { printf -- "** %s\n" "$*" >&2; } error() { printf -- "** ERROR: %s\n" "$*" >&2; } fatal() { error "$@"; exit 1; } -EXAMPLE=APIGateway +EXAMPLE=APIGatewayV2 OUTPUT_DIR=.build/release OUTPUT_FILE=${OUTPUT_DIR}/APIGatewayLambda LIBS_TO_CHECK="libFoundation.so libFoundationInternationalization.so lib_FoundationICU.so"