Swiftpack.co - Package - soto-project/soto-core

Soto Core

Swift 5.1 Codecov Result

The core framework for Soto the Swift SDK for AWS.

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 soto-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 soto-core. Version 3.x of soto-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 soto-core with Vapor 3. Below is a compatibility table for versions 3 and 4 of soto-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 |


We welcome and encourage contributions from all developers. Please read CONTRIBUTING.md for our contributing guidelines.


soto-core is released under the Apache 2.0 license. See LICENSE for details.


Stars: 72

Used By

Total: 0


v4.7.1 - 2020-09-21 07:57:29

Patch version changes

  • Removes duplicate "/" in InstanceMetaDataServiceProvider request to avoid redirect. PR #371 from @t089

v5.0.0 Beta 1.0 - 2020-09-18 07:42:42

AWS SDK Swift has been renamed to Soto

Major version changes

  • AWS SDK Swift Core has changed name and is now called SotoCore. The package name is "soto-core".
  • Body.json now holds a ByteBuffer instead of Data. PR #350
  • Add offset function parameter to AWSPayload.fileHandle. PR #352
  • Add 'context' parameter to AWSServiceMiddleware.chain() functions
  • AWSClient.signURL use HTTPMethod instead of a String for the http method.
  • Renamed TimeStampFormatterCoder to TimeStampFormatCoder and made it internal. PR #364

Minor version changes

  • AWSClient.HTTPResponseError is now public. This eases the writing of custom RetryPolicy objects.
  • Added AWSService a protocol for AWS services which provides helper vars to access the service region, endpoint and eventLoopGroup and a function for signing a URL for use by the service. PR #347
  • Added ByteBufferAllocator to AWSServiceConfig to be used throughout AWSClient. PR #351
  • Add pagination functions that include a test for a moreResults flag.
  • Add support to TimeStampFormatCoder for multiple time formats and add both with millisecond and without millisecond formats to the ISO8601TimeStampCoder. PR #364
  • Make AWSPayload.size public

Patch version changes

  • Provide common internal execute function used by all the public execute functions. PR #349
  • Fix bug in DeferredCredentialProvider where credential can be accessed and written at same time. PR #357
  • Add Glibc import at top of Expat.swift to aid cross compiler compilation
  • Tilda expansion for config file loading on macOS sandboxed apps expands to the home folder, instead of folder inside container. PR #361 from @sebsto
  • Fix v4 signer issue when the URL ends in a slash. This fixes signing issue for Lambda.ListFunctions. PR #363

v5.0.0 Alpha 6.0 - 2020-08-20 17:18:21

Major version changes

  • Use AsyncHTTPClient for macOS and iOS builds. This requires v1.2.0 of AsyncHTTPClient. NIOTSHTTPClient has been removed from the project. PR #339
  • Use Expat for XML parsing. This allows us to remove our dependency on FoundationXML. PR #342
  • Add RetryPolicyFactory setup in similar manner to the CredentialProviderFactory. Allows you to choose RetryPolicy using dot notation eg AWSClient(retryPolicy: .jitter(), ...). Also allows us to remove a number of public symbols. PR #323
  • AWSClient.ClientError is now a struct. PR #338
  • Add progress callback to AWSPayload.fileHandle. PR #334
  • Replace HTTP method string with enum NIOHTTP1.HTTPMethod. PR #329
  • Add logging to AWSClient. Pass in a swift-log Logger to output log information. PR #330, #331, #332
  • Partition renamed to AWSPartition
  • PayloadOptions renamed to AWSShapePayloadOptions. PR #322

Minor version changes

  • Add AWSClient.credentialProvider.shutdown() to shutdown AWSClient asynchronously. PR #327, #333
  • Add HTTP client timeout value to AWSServiceConfig. PR #328
  • Added ap-northeast-3 (Osaka Local) region.
  • AWSClient.credentialProvider is now public.

Internal changes

  • Use SwiftFormat for code formatting.

v4.7.0 - 2020-08-13 07:56:48

Add Region ap-northeast-3 (Asia Pacific (Osaka-Local))

v5.0.0 Alpha 5.1 - 2020-07-18 06:53:14

  • Use full .package() enum in Package.swift for swift-crypto package. This appears to resolve issues with latest version of swift 5.3

v5.0.0 Alpha 5.0 - 2020-07-06 07:11:46

Major version changes:

  • AWS Service configuration data is now stored in a AWSServiceConfig class.
  • Renamed AWSClient.send methods to execute. PR #309 from @Ro-M
  • AWSClient no longer owns the service configuration data. This is passed to the AWSClient in the execute methods. This allows us to separate the client from the services and have one client serving multiple services. PR #309 from @Ro-M
  • AWS Credentials are supplied via a CredentialProvider. Possible credential provider parameters are static: provide credentials directly, environment: from environment variables, ec2: from EC2 metadata, ecs: from ECS metadata, configFile: from ~/.aws/credentials file, empty: no credentials or selector: choose from a list of credential providers. If you don't provide a CredentialProvider the default is .selector(.environment, .ecs, .ec2, .configFile()). PR #258, #303, #314, #318, #306
  • Added support for streaming response payloads. This is only available if you are using AsyncHTTPClient though. PR #236
  • Added AWSClient.syncShutdown() to shutdown HTTPClient and any active CredentialProviders. It is required to call this before deleting the AWSClient. PR #293
  • Move XML code to separate target AWSXML. PR #271
  • Removed AWSMemberEncoding.encoding. Raw payload flag is now OptionSet entry PayloadOptions.raw. PR #294
  • AWSRequest uses NIO HTTPHeaders instead of a dictionary for headers. PR #301
  • AWSPayload.stream returns a StreamReaderResult instead of a ByteBuffer. Instead of returning an empty ByteBuffer to indicate the stream is done you now return .end. PR #316

Minor version changes:

  • S3 streamed requests are now signed. PR #277
  • Moved AWSClient.validate and AWSClient.createError to AWSResponse. PR #295
  • Moved AWSClient.createAWSRequest into AWSRequest.init. PR #296 from @Ro-M
  • AWSTestServer and TestUtils have been moved to separate target AWSTestUtils. PR #271
  • Requests are always signed using Authorization header. PR #272 by @Ro-M
  • Retry time calculation is more in line with aws-sdk-go sdk. PR #282
  • Set User-Agent header to "AWSSDKSwift/5.0". PR #288
  • Add port to host header. PR #291
  • Run middleware on AWSResponse in AWSClient.createError

Patch version changes:

  • The list of characters allowed in queries has been edited to be inline with AWS docs. PR #281
  • Replace all usages of String.components with String.split. PR #286
  • Provide better error messaging when we get an unparseable error. PR #287
  • Fixed crash when XML parser returned no XML.
  • Fixed head uri for NIOTSHTTPClient. It is no longer the full path. PR #298

v3.5.2 - 2020-07-03 10:20:18

Encode Foundation Data as base64 when encoding queries. This fixes an issue with SES.SendRawEmail()

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.