Swiftpack.co - Package - swift-aws/aws-sdk-swift-core


Swift 5.0 Codecov Result

A Core Framework for AWSSDKSwift

This is the underlying driver for executing requests to AWS, but you should likely use one of the libraries provided by the package above instead of this! Documentation can be found here.

Swift NIO

This client utilizes Swift NIO to power its interactions with AWS. It returns an EventLoopFuture in order to allow non-blocking frameworks to use this code. Please see the Swift NIO documentation for more details, and please let us know via an Issue if you have questions!


Versions 4.x of aws-sdk-swift-core are dependent on swift-nio 2, this means certain libraries/frameworks that are dependent on an earlier version of swift-nio will not work with version 4 of aws-sdk-swift-core. Version 3.x of the aws-sdk-swift-core can be used if you need to use an earlier version of swift-nio. For instance Vapor 3 uses swift-nio 1.13 so you can only use versions 3.x of aws-sdk-swift-core with Vapor 3. Below is a compatibility table for versions 3 and 4 of aws-sdk-swift-core.

| Version | Swift | MacOS | iOS | Linux | Vapor | |---------|-------|-------|--------|--------------------|--------| | 3.x | 4.2 - | ✓ | | Ubuntu 14.04-18.04 | 3.0 | | 4.x | 5.0 - | ✓ | 12.0 - | Ubuntu 14.04-18.04 | 4.0 |

Example Package.swift

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "MyAWSTool",
    dependencies: [
        .package(url: "https://github.com/swift-aws/aws-sdk-swift", from: "4.0.0"),
    targets: [
            name: "MyAWSTool",
            dependencies: ["CloudFront", "ELB", "IAM",  "S3"]),
            name: "MyAWSToolTests",
            dependencies: ["MyAWSTool"]),


aws-sdk-swift-core is released under the Apache 2.0 license. See LICENSE for details.


Stars: 61

Used By

Total: 0


v4.3.1 - 2020-03-25 23:00:04

Fixes for swift 5.2

v4.3.0 - 2020-03-24 16:03:53

  • Added AWSClient.region to access region client is working in.
  • Fixed up XML error parsing. Add tests for situation where error is enclosed in an additional XML Node.
  • Removed automatically setting "Accept" header to "/" as this was breaking some services

v4.2.4 - 2020-03-22 12:43:32

  • Fixed Query encoding of Foundation.Data (PR from @vkill)
  • Fixed ordering of headers in canonicalRequest while signing requests. Make sure we order them after lowercasing them, and not before. Fixes issue with signing of requests from Lambda.invoke()
  • Improved error handling for restjson services where the error code is in the response body.
  • Improved error handling for EC2, by returning a AWSResponseError with the error code in it, instead of an unrecognised error.

v4.2.3 - 2020-03-09 17:58:12

  • Mojave will not use the NIOTS version of the HTTPClient anymore as it crashes.
  • Fix issue with parsing errors from raw payload responses
  • Include response status code in AWSError

v4.2.2 - 2020-02-10 22:46:02

  • Update SwiftNIO version to bring in security update https://github.com/apple/swift-nio/releases/tag/2.13.1
  • Update SwiftNIOSSL version to bring in security update https://github.com/apple/swift-nio-ssl/security/advisories/GHSA-9556-94c5-c3j8

v3.5.1 - 2020-02-10 22:45:06

Update SwiftNIO version to pull in security update https://github.com/apple/swift-nio/releases/tag/1.14.2

v4.2.1 - 2020-02-05 18:12:41

  • Disabled the EC2 instance metadata service v2. This was causing code running in docker containers to hang.

v4.2.0 - 2020-01-26 17:10:08

  • Deprecated the typealias Future. From this point on you will need to use EventLoopFuture
  • Added support for EC2 Instance Metadata Service V2.
  • Refactored Hypertext Application Language Support. Removed unused link loading code that was broken.
  • Response middleware is now run after the HAL code has run.
  • Added support for processing paginated results from AWS services.

v4.1.0 - 2020-01-15 07:04:53

  • If GET request has a header, then sign request using "authorization" header instead of in the URL.
  • Allow xml decoder to decode attributes as members. This fixes #149
  • Added performance tests to profile various elements of aws-sdk-swift-core.
  • Remove the addition of `` around swift keywords when working out a swift variable name.
  • Optimization: Don't create default DateFormatter everytime we need it.
  • The dictionary encoder/decoder defaults to using base64 when encoding/decoding Foundation class Data.
  • Use NIOAtomic instead of Atomic in HTTPClient.
  • Use github action to rebuild documentation on publishing of a new release.

v3.5.0 - 2019-11-27 23:36:04

Adam Fowler:

  • Use AWSClient.eventLoopGroup in HTTPClient
  • Added swift build github action

v4.0.0 - 2019-11-22 07:44:29

Major version changes

  • aws-sdk-swift-core now requires Swift 5.0 or later.
  • We are now using Swift NIO 2.x. If you are dependent on a package using Swift NIO 1.14 or earlier eg Vapor 3, do not update to this version of aws-sdk-swift-core.
  • Re-worked HTTPClient so can work with NIO transport services. This means aws-sdk-swift-core works on iOS.
  • AWSClient.init() requires a EventLoopGroupProvider parameter, an enum with which you can provide your own eventLoopGroup for aws-sdk-swift-core to use, or use the one internal to AWSClient.

Other changes

  • If processing an XML response, ensure the header values in the response are also processed.
  • Tests now compile in release.
  • If AWSClient is initialised with accessKeyId and secretAccessKey set to "" then requests are sent to AWS unsigned. This gives access to AWS services such as CognitoIdentityProvider without credentials.
  • Refactored MetaDataService.

v3.4.0 - 2019-10-14 11:47:28

  • Fixed issue with compiling for Swift 5.1 on Linux.
  • Rename XMLContainerCodingMap to XMLCodable.
  • Move ShapeEncoding and Location enums inside AWSShapeMember.
  • Move Request, Response and HTTPClientError inside HTTPClient.
  • Remove middlewares and amzTarget parameters from AWSRequest.init(). These are applied elsewhere.

v3.3.0 - 2019-09-17 06:33:49

  • Added AWSLoggingMiddleware which logs raw requests sent to AWS and raw responses received back.
  • Changed restjson protocol Content-Type header to be 'application/json'.
  • Created AWSResponse struct which holds a processed response.
  • Middleware now has the ability to edit the contents of a AWSResponse.
  • Separated service signing name from service endpoint name as these can sometimes be different. This affects V4.Signer.init() where the service parameter has been renamed to signingName.
  • If response has a payload path then create top level objects to contain the response json or xml.
  • Mac uses CommonCrypto for SHA256, HMAC and MD5 calculations.
  • Added AWSClient.signURL() to return a signed URL.
  • AWSErrorType now conforms to CustomStringConvertible.
  • Add additional methods for decoding timestamps (HTTP date format and seconds from UNIX epoch time).
  • AWSClient.send() functions don't throw errors so have removed throws from them.
  • Min/max collection length validation errors output the length and not the full collection.
  • String pattern validation does not expect the whole string to match the pattern.

v3.2.0 - 2019-08-17 22:24:06

  • If dictionary decoder expects an array but doesn't find one then stick object found inside an array. Fixes issue in API Gateway where single element arrays are just returned as the element.
  • AWSClient.init() has a new sessionToken parameter.
  • Add session tokens to headers before constructing authorization header.
  • XML Parser ignores newlines as well as whitespace in between XML nodes.
  • Don't encode single or double quotation marks in XML
  • Added general purpose validation code to be used by auto-generated validate() functions in aws-sdk-swift.
  • Added AWSShape.idempotencyToken() for auto-generating idempotency tokens.
  • Added support for OpenSSL 1.1 while still supporting earlier versions.
  • New me-south-1 region is available.
  • Added the ability to edit response bodies before they are decoded into an AWSShape.

v3.1.1 - 2019-07-19 01:20:03

Adam Fowler: XML: If text is completely white space don't add a text node

v3.1.0 - 2019-07-12 16:35:04

Adam Fowler: Use Codable for serializing XML requests and parsing XML responses Using query encoder for ec2 Added xmlNamespace to the root payload xml element when required Only add a body to an AWSRequest if there are shape members that are included in the body Store Timestamp internally as a Date Add DictionaryEncoder and use this when encoding JSON payloads Decode JSON dictionary data as base64 Add encoding hints for serializing arrays and dictionaries. Hints include naming of XML, query elements and whether container is flattened Percent encode more characters in query body Add code for ec2 to flatten all arrays, regardless of encoding hints Added regions ap-east-1, eu-west-3 and eu-north-1 Updated core XML loader

giginet: Avoid warning on Xcode

v3.0.1 - 2019-05-19 22:28:41

  • return Future instead of Void so clients can chain off the response and catch errors
  • normalize status code valdiation validate status code on methods with no response

v3.0.0 - 2019-05-17 18:45:39

Adam Fowler: Fixed Incorrect stringToSign created for API calls that include query parameters without assignation. Fixed it by ensuring we never send nil parameters to V4 Signer. Added test for signing AWSRequest Fix = sign being percent encoded twice

Joe Smith: Utilize the officially sanctioned docker image to handle tests (#59) Quiet the xcodebuild logs and run in parallel (#64)

Jonathan McAllister: refactor send to return Futures add typalias Future as shorthand for EventLoopFuture ensure url.hostWithPort is not nil update nio to 1.14 fix warning for redundant modifiers refactor getCredential to return a future and move it back to the client class fix HEAD requests throw InvalidRequest Error instead of fatalError if uri is invalid add token to signedURL if the credential has one log resonse http status code for Unhandled errors do not populate a body for restxml requests that do not have a payloadPath. Input is headers only if there is no payloadPath on restxml APIs HEAD request is just a GET request with the HEAD method - remove content-type for head request - use signed url for HEAD requests

noppoman: resurrect user specific endpoint request add default value for endpoint add test for custom endpoint signing

2.0.0-rc.5 - 2019-02-14 22:42:31

  • properly serialize the payloadPath object as json / xml if the shape has a payload path and it defines a shape (Glacier, etc)

2.0.0-rc.4 - 2019-01-12 21:45:25

Jonathan McAllister: handle when path includes query params

- 2018-12-07 06:49:54

2.0.0-rc.2 - 2018-11-16 03:36:37

Joe Smith: Take advantage of ISO8601DateFormatter on macOS 10.12 and greater. (#33) Improve XML list parsing (#36)

Jonathan McAllister: use URLComponents to build urls including query parameters add intelligence around when we set params in the url vs body based on the httpMethod set header content-type to application/x-www-form-urlencoded on query POST requests update nio and nio-ssl to latest 1.x versions (#38) 39 use NIOFoundationCompat instead of rewriting ByteBuffer (#40)

Oliver O'Neill: Add shared credentials support (#35)

- 2018-06-08 14:51:51

- 2018-04-13 08:14:12

- 2017-12-15 05:25:15

- 2017-12-13 04:04:26

- 2017-12-09 18:42:48

Improve external representation and object mapping - 2017-11-17 16:51:46

  • If the response type has payloadPath, the responded body data should be handled as buffer not external representation.
  • More robust mapping process between external representation and object. It's necessary for successfully decoding with Swift's Decoder
    • Convert the value in XML to JSON native type if the value is meaningful for JSON. (e.g, "null" => null, "3.1" => Double: 3.1)
    • Convert the header value to number if it can cast Double. (e.g "1" => Int: 1, "1.1" => Double: 1.1)

- 2017-10-09 19:02:04

- 2017-10-08 17:47:05