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


Swift 5.1 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: 64

Used By

Total: 0


v4.6.0 - 2020-06-02 13:50:46

  • Upped swift-nio version package requirements to ensure we get swift 5.3 versions
  • Ensure EC2 labels all have their first letter uppercased

v5.0.0 Alpha 4.0 - 2020-05-21 09:37:37

Major version changes:

  • AWSPayload is used for payloads in responses. PR #243
  • Use property wrappers to define how collections are encoded/decoded. PR #215
  • Added ability to stream request payloads. Added AWSPayload.stream which has a function that provides ByteBuffers to a request. Added AWSPayload.fileHandle which streams a file for a request.
  • Added support for all AWS partitions. This gives access to china and government regions. PR #242
  • Region is now a struct so we can add new regions without requiring a major version change. PR #246
  • Change AWSClientError and AWSServerError to structs so they can be extended without a major version change. Removed some service specific errors from them. PR #247
  • Renamed RetryController to RetryPolicy and defaulted it to JitterRetry which retries failed requests with a random wait time taken from an exponential increasing range.

Minor version changes:

  • AWSClient.httpClient is now public
  • Added TimeStampCoder property wrappers that enforces how a TimeStamp would be encoded/decoded. PR #249
  • Added RED (Request, Error, Durarion) metrics using swift-metrics. PR #245

Patch version changes:

  • Check for os Linux instead of availability of swift-crypto when chosing between which crypto to run.
  • Don't set Content-Type header if it is already set
  • Fixed issue with decoding empty XML arrays
  • Add query encoding specialisation for EC2. EC2 requires all query variables to have their first character capitalised. PR #253
  • Added iOS CI
  • Replace using ProcessInfo to get environment variables with the C function getenv. PR #257

v4.5.1 - 2020-05-10 16:21:45

  • Check to see if "Content-Type" header is set before setting default content type.

v5.0.0 Alpha 3.3 - 2020-05-09 10:39:01

  • Fixed compilation issue when compiling with another library that has swift-crypto as a dependency.

v4.5.0 - 2020-05-01 13:44:31

Minor version changes:

  • Added regions af-south-1 and eu-south-1

Patch version changes:

  • Fixed issue where "x-amz-target" header wasn't getting set

v5.0.0 Alpha 3.2 - 2020-05-01 11:10:23

  • Added region eu-south-1

v5.0.0 Alpha 3.1 - 2020-05-01 11:05:05

  • Added region af-south-1

v5.0.0 Alpha 3.0 - 2020-05-01 10:58:01

Major version changes:

  • Allow user to set the HTTP client for AWSClient. This has replaced setting the EventLoopGroup. This means you provide a HTTP client with your own setup. If you are using AsyncHTTPClient this includes proxy settings, response decompression and timeouts. The EventLoopGroup AWSClient uses will be the same one the HTTP client uses. PR #203
  • Add on: EventLoop parameter to all the commands to force the EventLoop AWSClient will use. This has one restriction in that the EventLoop has to come from the EventLoopGroup being used by the client. PR #240
  • Simplified the service protocol, reducing it to an enum. #241

Minor version changes:

  • Group all service configuration data into one ServiceConfig object. #239

v5.0.0 Alpha 2.0 - 2020-04-18 08:16:40

Major version changes

  • Split AWSShape into AWSEncodableShape and AWSDecodableShape. PR #214
  • Added AWSShapeWithPayload for shapes with a payload. PR #214
  • Added AWSPayload for raw data payload objects. Internally this is a ByteBuffer, but it can be initialised with Data, String or ByteBuffer. PR #218
  • Reduced pagination token protocols down to a single protocol AWSPaginationToken with associated type. PR #231
  • XMLEncoder, XMLDecoder, DictionaryDecoder and QueryEncoder are no longer public.
  • Removed URL.hostWithPort extension.
  • AWSLoggingMiddleware is now a struct

Minor version changes

  • Added ability to extract the response status code and serialize into AWSShape. #234
  • The user can provide an arbitrarily named region now using .other(myregion). PR #228
  • Added query serialization of Dictionaries. #235
  • Added support for retrying requests if they return an error. This is currently default to off.

Patch version changes

  • Fixed an issue where in a rare case the query parameters were not being sorted correctly

v4.4.0 - 2020-04-15 15:57:26

  • Upped swift-nio-ssl version requirement to 2.6.0 and above

v5.0.0 Alpha 1.0 - 2020-04-04 10:31:08

This is the first alpha release of v5.0.0. There will be a number of future alpha releases each which could include more breaking changes.

Major version changes:

  • On Linux we are using the AsyncHTTPClient to serve our HTTP requests. On macOS, iOS we are using a NIOTSHTTPClient internal to aws-sdk-swift-core. This is a reduced version of the old HTTPClient with only NIOTransportServices support. You can get macOS to use the AsyncHTTPClient by providing a MultithreadedEventLoopGroup to AWSClient. PR #141
  • The URL/Header signing code has been completely rewritten and can be found here in a separate module AWSSignerV4.
  • Added AWSCrypto module which wraps crypto functions. The Linux build uses swift-crypto while AWSCrypto provides macOS and iOS with drop in replacements, using CommonCrypto, for the functions we use. This is to avoid forcing all our users onto macOS 10.15 and iOS 13.0. PR #197
  • Removed the typealias Future = EventLoopFuture. PR #229
  • CredentialProvider has been renamed to Credential.
  • Removed dependency on HypertextApplicationLanguage package. We don't need the majority of this code. The small bit we require has been implemented in aws-sdk-swift-core. PR #189
  • Remove dependency on INIParser package. Instead we vendor the code from within aws-sdk-swift-core. PR #206
  • Cleaned up AWSShapeMember. Removed unnecessary members 'required' and 'type', renamed AWSShapeMember to AWSMemberEncoding, renamed _members to _encoding.removed all String extensions used by AWSShapeMember code, getEncoding(forLocation: String) is now getEncoding(forKey: CodingKey). Don't assume every AWSShape member has an equivalent AWSShapeMember. PR #205
  • Body.buffer() now holds a ByteBuffer instead of Data PR #200
  • Package name has changed from AWSSDKSwiftCore to aws-sdk-swift-core to ease adding it as a dependency in swift 5.2 package files.

Minor version changes:

  • Added Support for EC2 Instance Meta v2. PR #184
  • HTTP Client is created at AWSClient initialization, so the same http client can be used throughout.
  • Queries are encoded using the Codable system. Now all request body encoding and response body decoding uses Codable. PR #187
  • Added encoding functions to AWSShape. This allows us to encode Payload objects directly and removes any requirement for a DictionaryEncoder. So this has been removed from the project. PR #212

Patch version changes:

  • Fixed XML container encoding not being reset while encoding/decoding arrays of non-trivial objects.
  • Fixed errors from requests expecting a raw data result not being parsed correctly.
  • Fixed various error parsing issues, where errors were inside additional XML nodes.
  • Return EC2 Error codes.
  • Allow for query values that are arrays. Serialize them as entry=value1&entry=value2.

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)