Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 3e856d9

Browse files
Merge branch 'feature/update-s3-example' into feature/amazonlinux2
2 parents f42f3d4 + dd5f62b commit 3e856d9

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
lambda.zip
77
swift-shared-libs
88
default.profraw
9+
.swiftpm

Examples/S3Test/Package.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.1
22

33
import PackageDescription
44

55
let package = Package(
66
name: "S3Test",
7+
products: [
8+
.executable(name: "S3Test", targets: ["S3Test"])
9+
],
710
dependencies: [
811
// Dependencies declare other packages that this package depends on.
912
// .package(url: /* package url */, from: "1.0.0"),
1013
//.package(path: "../../../aws-lambda-swift-sprinter-core"),
1114
//.package(url: "https://github.com/swift-sprinter/aws-lambda-swift-sprinter-core", from: "1.0.0-alpha.3"),
1215
//.package(path: "../../../aws-lambda-swift-sprinter-nio-plugin"),
1316
.package(url: "https://github.com/swift-sprinter/aws-lambda-swift-sprinter-nio-plugin", from: "1.0.0"),
14-
.package(url: "https://github.com/swift-aws/aws-sdk-swift.git", from: "4.0.0"),
17+
.package(url: "https://github.com/swift-aws/aws-sdk-swift.git", from: "5.0.0-alpha.3"),
1518
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
1619
],
1720
targets: [
1821
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
1922
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
2023
.target(
2124
name: "S3Test",
22-
dependencies: ["LambdaSwiftSprinterNioPlugin", "S3", "Logging"]
25+
dependencies: [
26+
"LambdaSwiftSprinterNioPlugin",
27+
.product(name: "AWSS3", package: "aws-sdk-swift"),
28+
"Logging"
29+
]
2330
),
2431
.testTarget(
2532
name: "S3TestTests",

Examples/S3Test/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import Foundation
2222
#endif
2323
import LambdaSwiftSprinterNioPlugin
2424
import Logging
25-
import S3
25+
import AWSS3
2626
import NIO
2727
import NIOFoundationCompat
28+
import AWSSDKSwiftCore
2829

2930
struct Bucket: Codable {
3031
let name: String
@@ -39,7 +40,10 @@ struct Response: Codable {
3940
Change the region with the region of your S3 bucket.
4041

4142
```swift
42-
let s3 = S3(region: .euwest1)
43+
guard let awsClient: AWSHTTPClient = httpClient as? AWSHTTPClient else {
44+
preconditionFailure()
45+
}
46+
let s3 = S3(region: .euwest1, httpClientProvider: .shared(awsClient))
4347
```
4448

4549
add a logger:

Examples/S3Test/Sources/S3Test/main.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818
#endif
1919
import LambdaSwiftSprinterNioPlugin
2020
import Logging
21-
import S3
21+
import AWSS3
2222
import NIO
2323
import NIOFoundationCompat
2424
import AWSSDKSwiftCore
@@ -36,18 +36,22 @@ let logger = Logger(label: "AWS.Lambda.S3Test")
3636

3737
var s3: S3!
3838

39+
guard let awsClient: AWSHTTPClient = httpClient as? AWSHTTPClient else {
40+
preconditionFailure()
41+
}
42+
3943
if ProcessInfo.processInfo.environment["LAMB_CI_EXEC"] == "1" {
4044
//Used for local test
4145
s3 = S3(region: .useast1, endpoint: "http://localstack:4572")
4246
logger.info("Endpoint-URI: http://localstack:4572")
43-
} else if let awsRegion = ProcessInfo.processInfo.environment["AWS_REGION"],
47+
} else if let awsRegion = ProcessInfo.processInfo.environment["AWS_REGION"] {
4448
//The S3 Bucket must be in the same region of the Lambda
45-
let region = Region(rawValue: awsRegion) {
46-
s3 = S3(region: region)
49+
let region = Region(rawValue: awsRegion)
50+
s3 = S3(region: region, httpClientProvider: .shared(awsClient))
4751
logger.info("AWS_REGION: \(region)")
4852
} else {
4953
//Default configuration
50-
s3 = S3(region: .useast1)
54+
s3 = S3(region: .useast1, httpClientProvider: .shared(awsClient))
5155
logger.info("AWS_REGION: us-east-1")
5256
}
5357

0 commit comments

Comments
 (0)