diff --git a/Examples/Deployment/README.md b/Examples/Deployment/README.md index 6066383d..33d27fc9 100644 --- a/Examples/Deployment/README.md +++ b/Examples/Deployment/README.md @@ -87,7 +87,7 @@ The SAM template will provide an output labelled `LambdaApiGatewayEndpoint` whic ``` curl <> - ``` + ``` ***Warning:*** This SAM template is only intended as a sample and creates a publicly accessible HTTP endpoint. @@ -162,7 +162,7 @@ For example: ``` curl https://r39lvhfng3.execute-api.us-east-1.amazonaws.com/api - ``` + ``` ***Warning:*** This Serverless template is only intended as a sample and creates a publicly accessible HTTP endpoint. diff --git a/Examples/Deployment/scripts/SAM/APIGateway-template.yml b/Examples/Deployment/scripts/SAM/APIGateway-template.yml deleted file mode 100644 index 7776921b..00000000 --- a/Examples/Deployment/scripts/SAM/APIGateway-template.yml +++ /dev/null @@ -1,30 +0,0 @@ -AWSTemplateFormatVersion : '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: A sample SAM template for deploying Lambda functions. - -Resources: -# APIGateway Function - apiGatewayFunction: - Type: AWS::Serverless::Function - Properties: - Handler: Provided - Runtime: provided - CodeUri: ../../.build/lambda/APIGateway/lambda.zip -# Add an API Gateway event source for the Lambda - Events: - HttpGet: - Type: HttpApi - Properties: - ApiId: !Ref lambdaApiGateway - Path: '/samples/apig' - Method: GET -# Instructs new versions to be published to an alias named "live". - AutoPublishAlias: live - - lambdaApiGateway: - Type: AWS::Serverless::HttpApi - -Outputs: - LambdaApiGatewayEndpoint: - Description: 'API Gateway endpoint URL.' - Value: !Sub 'https://${lambdaApiGateway}.execute-api.${AWS::Region}.amazonaws.com/samples/apig' diff --git a/Examples/Deployment/scripts/serverless/APIGateway-template.yml b/Examples/Deployment/scripts/serverless/APIGateway-template.yml deleted file mode 100644 index 6787ad0f..00000000 --- a/Examples/Deployment/scripts/serverless/APIGateway-template.yml +++ /dev/null @@ -1,28 +0,0 @@ -service: apigateway-swift-aws - -package: - artifact: .build/lambda/APIGateway/lambda.zip - -provider: - name: aws - httpApi: - payload: '2.0' - runtime: provided - logs: - httpApi: true - iamRoleStatements: - - Effect: Allow - Action: - - logs:CreateLogGroup - - logs:CreateLogStream - - logs:PutLogEvents - Resource: "*" - -functions: - httpGet: - handler: APIGateway - memorySize: 128 - events: - - httpApi: - method: GET - path: /api \ No newline at end of file diff --git a/Examples/Deployment/scripts/serverless/Benchmark-template.yml b/Examples/Deployment/scripts/serverless/Benchmark-template.yml index 74099441..1b2b1940 100644 --- a/Examples/Deployment/scripts/serverless/Benchmark-template.yml +++ b/Examples/Deployment/scripts/serverless/Benchmark-template.yml @@ -12,7 +12,7 @@ provider: - logs:CreateLogGroup - logs:CreateLogStream - logs:PutLogEvents - Resource: "*" + Resource: "*" functions: benchmarkFunction: diff --git a/Examples/Deployment/scripts/serverless/HelloWorld-template.yml b/Examples/Deployment/scripts/serverless/HelloWorld-template.yml index 276f9909..8d12bb74 100644 --- a/Examples/Deployment/scripts/serverless/HelloWorld-template.yml +++ b/Examples/Deployment/scripts/serverless/HelloWorld-template.yml @@ -12,7 +12,7 @@ provider: - logs:CreateLogGroup - logs:CreateLogStream - logs:PutLogEvents - Resource: "*" + Resource: "*" functions: hello: diff --git a/Sources/AWSLambdaRuntimeCore/Lambda.swift b/Sources/AWSLambdaRuntimeCore/Lambda.swift index a4a04cd7..d54d0192 100644 --- a/Sources/AWSLambdaRuntimeCore/Lambda.swift +++ b/Sources/AWSLambdaRuntimeCore/Lambda.swift @@ -53,7 +53,7 @@ public enum Lambda { return String(cString: value) } - #if swift(>=5.5) + #if compiler(>=5.5) && canImport(_Concurrency) // for testing and internal use @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) internal static func run(configuration: Configuration = .init(), handlerType: Handler.Type) -> Result { diff --git a/Sources/AWSLambdaRuntimeCore/LambdaHandler.swift b/Sources/AWSLambdaRuntimeCore/LambdaHandler.swift index d9fd68f8..f0a9d256 100644 --- a/Sources/AWSLambdaRuntimeCore/LambdaHandler.swift +++ b/Sources/AWSLambdaRuntimeCore/LambdaHandler.swift @@ -17,7 +17,7 @@ import NIOCore // MARK: - LambdaHandler -#if compiler(>=5.5) +#if compiler(>=5.5) && canImport(_Concurrency) /// Strongly typed, processing protocol for a Lambda that takes a user defined `Event` and returns a user defined `Output` async. @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) public protocol LambdaHandler: EventLoopLambdaHandler { diff --git a/Sources/AWSLambdaTesting/Lambda+Testing.swift b/Sources/AWSLambdaTesting/Lambda+Testing.swift index 7180a204..f514f38f 100644 --- a/Sources/AWSLambdaTesting/Lambda+Testing.swift +++ b/Sources/AWSLambdaTesting/Lambda+Testing.swift @@ -33,9 +33,8 @@ // XCTAssertEqual(result, "echo" + input) // } -#if swift(>=5.5) +#if compiler(>=5.5) && canImport(_Concurrency) import AWSLambdaRuntime -import AWSLambdaRuntimeCore import Dispatch import Logging import NIOCore diff --git a/Tests/AWSLambdaRuntimeCoreTests/LambdaHandlerTest.swift b/Tests/AWSLambdaRuntimeCoreTests/LambdaHandlerTest.swift index 27c79e98..27290d54 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/LambdaHandlerTest.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/LambdaHandlerTest.swift @@ -17,7 +17,7 @@ import NIOCore import XCTest class LambdaHandlerTest: XCTestCase { - #if compiler(>=5.5) + #if compiler(>=5.5) && canImport(_Concurrency) // MARK: - LambdaHandler diff --git a/Tests/AWSLambdaRuntimeTests/Lambda+CodeableTest.swift b/Tests/AWSLambdaRuntimeTests/Lambda+CodableTest.swift similarity index 98% rename from Tests/AWSLambdaRuntimeTests/Lambda+CodeableTest.swift rename to Tests/AWSLambdaRuntimeTests/Lambda+CodableTest.swift index 6f10bfc9..214631ad 100644 --- a/Tests/AWSLambdaRuntimeTests/Lambda+CodeableTest.swift +++ b/Tests/AWSLambdaRuntimeTests/Lambda+CodableTest.swift @@ -82,7 +82,7 @@ class CodableLambdaTest: XCTestCase { XCTAssertEqual(response?.requestId, request.requestId) } - #if swift(>=5.5) + #if compiler(>=5.5) && canImport(_Concurrency) @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) func testCodableVoidHandler() { struct Handler: LambdaHandler { @@ -183,7 +183,7 @@ private struct Response: Codable, Equatable { } } -#if swift(>=5.5) +#if compiler(>=5.5) && canImport(_Concurrency) // NOTE: workaround until we have async test support on linux // https://github.com/apple/swift-corelibs-xctest/pull/326 extension XCTestCase { diff --git a/Tests/AWSLambdaTestingTests/Tests.swift b/Tests/AWSLambdaTestingTests/Tests.swift index 83ac4217..5801f605 100644 --- a/Tests/AWSLambdaTestingTests/Tests.swift +++ b/Tests/AWSLambdaTestingTests/Tests.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#if swift(>=5.5) +#if compiler(>=5.5) && canImport(_Concurrency) import AWSLambdaRuntime import AWSLambdaTesting import NIOCore diff --git a/readme.md b/readme.md index a4e5238f..38d71d2c 100644 --- a/readme.md +++ b/readme.md @@ -144,7 +144,7 @@ First, add a dependency on the event packages: Beyond the small cognitive complexity of using the `EventLoopFuture` based APIs, note these APIs should be used with extra care. An `EventLoopLambdaHandler` will execute the user code on the same `EventLoop` (thread) as the library, making processing faster but requiring the user code to never call blocking APIs as it might prevent the underlying process from functioning. -## Deploying to AWS Lambda +## Deploying to AWS Lambda To deploy Lambda functions to AWS Lambda, you need to compile the code for Amazon Linux which is the OS used on AWS Lambda microVMs, package it as a Zip file, and upload to AWS. @@ -160,7 +160,7 @@ The library defines three protocols for the implementation of a Lambda Handler. ### ByteBufferLambdaHandler -An `EventLoopFuture` based processing protocol for a Lambda that takes a `ByteBuffer` and returns a `ByteBuffer?` asynchronously. +An `EventLoopFuture` based processing protocol for a Lambda that takes a `ByteBuffer` and returns a `ByteBuffer?` asynchronously. `ByteBufferLambdaHandler` is the lowest level protocol designed to power the higher level `EventLoopLambdaHandler` and `LambdaHandler` based APIs. Users are not expected to use this protocol, though some performance sensitive applications that operate at the `ByteBuffer` level or have special serialization needs may choose to do so.