Giter Club home page Giter Club logo

soto's Introduction

Soto for AWS

sswg:incubating|104x20 Swift 5.4

Soto is a Swift language SDK for Amazon Web Services (AWS), working on Linux, macOS and iOS. This library provides access to all AWS services. The service APIs it provides are a direct mapping of the REST APIs Amazon publishes for each of its services. Soto is a community supported project and is in no way affiliated with AWS.

Table of Contents

Structure

The library consists of three parts

  1. soto-core which does all the core request encoding and signing, response decoding and error handling.
  2. The service api files which define the individual AWS services and their commands with their input and output structures.
  3. The CodeGenerator which builds the service api files from the JSON model files supplied by Amazon.

Swift Package Manager

Soto uses the Swift Package Manager to manage its code dependencies. To use Soto in your codebase it is recommended you do the same. Add a dependency to the package in your own Package.swift dependencies.

    dependencies: [
        .package(url: "https://github.com/soto-project/soto.git", from: "6.0.0")
    ],

Then add target dependencies for each of the Soto targets you want to use.

    targets: [
        .target(name: "MyApp", dependencies: [
            .product(name: "SotoS3", package: "soto"),
            .product(name: "SotoSES", package: "soto"),
            .product(name: "SotoIAM", package: "soto")
        ]),
    ]
)

Alternatively if you are using Xcode 11 or later you can use the Swift Package Manager integration and add a dependency to Soto through that.

Compatibility

Soto works on Linux, macOS and iOS. It requires v2.0 of Swift NIO. Below is a compatibility table for different Soto versions.

Version Swift MacOS iOS Linux Vapor
6.x 5.4 - 12.0 - Ubuntu 18.04-22.04 4.0
5.x 5.2 - 12.0 - Ubuntu 18.04-20.04 4.0

Configuring Credentials

Before using the SDK, you will need AWS credentials to sign all your requests. Credentials can be provided to the library in the following ways.

  • Environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  • ECS container IAM policy
  • EC2 IAM instance profile
  • Shared credentials file in your home directory
  • Static credentials provided at runtime

You can find out more about credential providers here

Using Soto

To use Soto you need to create an AWSClient and a service object for the AWS service you want to work with. The AWSClient provides all the communication with AWS and the service object provides the configuration and APIs for communicating with a specific AWS service. More can be found out about AWSClient here and the AWS service objects here.

import SotoS3 //ensure this module is specified as a dependency in your package.swift

let bucket = "my-bucket"

let client = AWSClient(
    credentialProvider: .static(accessKeyId: "Your-Access-Key", secretAccessKey: "Your-Secret-Key"),
    httpClientProvider: .createNew
)
let s3 = S3(client: client, region: .uswest2)

func createBucketPutGetObject() async throws -> S3.GetObjectOutput {
    // Create Bucket, Put an Object, Get the Object
    let createBucketRequest = S3.CreateBucketRequest(bucket: bucket)
    _ = try await s3.createBucket(createBucketRequest)
    // Upload text file to the s3
    let bodyData = "hello world"
    let putObjectRequest = S3.PutObjectRequest(
        acl: .publicRead,
        body: .string(bodyData),
        bucket: bucket,
        key: "hello.txt"
    )
    _ = try await s3.putObject(putObjectRequest)
    // download text file just uploaded to S3
    let getObjectRequest = S3.GetObjectRequest(bucket: bucket, key: "hello.txt")
    let response = try await s3.getObject(getObjectRequest)
    // print contents of response
    if let body = response.body?.asString() {
        print(body)
    }
    return response
}

Build Plugin

Soto is a vary large package. If you would rather not include it in your package dependencies you can instead use the SotoCodeGenerator Swift Package Manager build plugin to generate the Swift source code for only the services/operations you actually need. Find out more here.

Documentation

API Reference

Visit soto.codes to browse the user guides and api reference. As there is a one-to-one correspondence with AWS REST api calls and the Soto api calls, you can also use the official AWS documentation for more detailed information about AWS commands.

User guides

Additional user guides for specific elements of Soto are available

Contributing

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

License

Soto is released under the Apache License, Version 2.0. See LICENSE for details.

Backers

Support development of Soto by becoming a backer

soto's People

Contributors

0xtim avatar adam-fowler avatar andrea-scuderi avatar fabianfett avatar jmoisan21 avatar jonnymacs avatar nicksloan avatar noppoman avatar ro-m avatar sebsto avatar tengyifei avatar yasumoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soto's Issues

Parse/Generate enum type in api doc

For example
api-s3.json

    "BucketLocationConstraint":{
      "type":"string",
      "enum":[
        "EU",
        "eu-west-1",
        "us-west-1",
        "us-west-2",
        "ap-south-1",
        "ap-southeast-1",
        "ap-southeast-2",
        "ap-northeast-1",
        "sa-east-1",
        "cn-north-1",
        "eu-central-1"
      ]
    },

SES Illegal Address error

Trying to send emails I get the error Illegal address, it appears that the final payload sent to AWS SES is wrong:

Action=SendEmail&Destination.ToAddresses.member.1=%5B%[email protected]%22%5D&Message.Body.Text.Data=…

Specifically Destination.ToAddresses.member.1=%5B%[email protected]%22%5D is the URL encoding for[[email protected]] where the docs for SES do not enclose the string we provide in square brackets.

It should be: [email protected]

Using v2.0.0. Thanks.

Code:

let recipient = "[email protected]"

 _ = try ses.sendEmail(.init(
    destination: .init(toAddresses: [recipient]),
    source: "[email protected]",
    replyToAddresses: [],
    returnPath: "",
    message: .init(
    subject: .init(data: subject),
        body: .init(html: nil,
        text: .init(data: body))),
    sourceArn: "",
    returnPathArn: ""))

How to install this?

Could you provide some instructions on how to install this package?
I'm not new to XCode and not very new to Swift, but new to SPM.
What do we do after downloading this?
How do we build it? I tried and got an error.
How do we tell our project in XCode to reference this package so Import will work?

Thank you.

S3 listObjectsV2 Hangs waiting for response

I'm using Mac OS 10.14.2 aws-sdk-swift 2.0.2 S3 and my request is hanging on the following call, however, I don't believe it has to do with the specific call.

This hangs:

let request = S3.ListObjectsV2Request(bucket: bucketName)
let response = try s3.listObjectsV2(request)

This is working fine:

let request = S3.ListObjectsRequest(bucket: bucketName)
let response = try s3.listObjects(request)

It appears to be hanging in:

extension AWSClient {
    fileprivate func invoke(_ nioRequest: Request) throws -> Response {
        let client = HTTPClient(hostname: nioRequest.head.headers["Host"].first!, port: 443)
        let future = try client.connect(nioRequest)

        //TODO(jmca) don't block
        let response = try future.wait()

Issue with session tokens?

I'm trying to use this SDK with credentials obtained via Okta. The Okta integration generates a profile in the credentials file that includes a session token. When using this SDK I always get the error The AWS Access Key Id you provided does not exist in our records.

The aws CLI tool works without error. I also tested the Ruby SDK which works.

Glacier APIs, always throw exception "Required parameter missing: API version"

It seems like all the Glacier code is throwing the same error. The following code

do {
    let glacier = Glacier(region:.euwest2)
    let description = try glacier.describeVault(Glacier.DescribeVaultInput(vaultName:"vaultName", accountId:"-"))
    print(description)
} catch let error {
    print(error)
}

Always outputs the following error

AWSError(message: "Required parameter missing: API version", rawBody: "{\"code\":\"MissingParameterValueException\",\"message\":\"Required parameter missing: API version\",\"type\":\"Client\"}")

I've tried this with listVaults() and listJobs() with the same results

Issues supplying APNs SSL certificate and private key to createPlatformApplication

To get Apple Push Notifications working with the AWS SNS system you need to setup a platform application. The platform application creation requires an SSL certificate and a private key that Apple provides. You supply them as follows

        var attributes : [String : String] = [
            "PlatformCredential" : privateKey,
            "PlatformPrincipal" : SSLCertificate
            ]
        
        let createApplicationInput = SNS.CreatePlatformApplicationInput(attributes:attributes, name:applicationName, platform:"APNS_SANDBOX")
        let createApplicationResponse = try sns.createPlatformApplication(createApplicationInput)

I am providing them in the form

-----BEGIN CERTIFICATE-----
MIIEKJHKhkjjsndfmnisudf...
-----END CERTIFICATE-----

and

-----BEGIN PRIVATE KEY-----
MIIEkjjgusdfdfjjnemn/sdfhkjsdf
-----END PRIVATE KEY-----

The call fails though with the following error
AWSResponseError(errorCode: "MalformedInput", message: Optional("Value found where not expected"))

Cognito user attributes type

Hi Mantainers!

Thank you for all the effort that you have put into this library, is fantastic to use and very well documented. I was using CognitoIdentityProvider for one of my lambdas and I realized that the User attributes is an array type AttributeListType when it would be easier to use if it where a dictionary.

https://github.com/swift-aws/aws-sdk-swift/blob/23ecff293ad950d1dcae7d7745474835c444cbc7/models/apis/cognito-idp/2016-04-18/api-2.json#L2400-L2403

What do you think? I'm happy to submit a PR if we want to move forward with this change.

Is it possible to use CognitoIdentityPool for identification?

Hello

Thanks for great library and sorry for lame question.
I'm porting some old code to new platform and stuck on subject.

More precise question. Can I expect that this code return identity without any configured credentials?

let client = CognitoIdentity(region: .useast1)
let request = CognitoIdentity.GetIdInput(identityPoolId: AWSLink.poolId)
let id = try client.getId(request) // <-- locks here
Log.debug(message: "received id: \(id)")

Thanks

Decoding error on response of ECS.describeServices

While requesting API for ECS.describeServices, I have got an error:

dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "services", intValue: nil), _DictionaryKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "propagateTags", intValue: nil)], debugDescription: "Cannot initialize PropagateTags from invalid String value NONE", underlyingError: nil))

My actual raw json response is:

...\"propagateTags\":\"NONE\",...

Here is definition of PropagateTags in Swift.

public enum PropagateTags: String, CustomStringConvertible, Codable {
    case taskDefinition = "TASK_DEFINITION"
    case service = "SERVICE"
}

NONE is missing or models is outdated?

Precondition-fail in Swift-NIO

I use version 2.0.2 of "aws-sdk-swift".

Using the code below, I get a precondition failure in Swift-NIO.

            let bucket = "xxx-storage"
            let s3 = S3(
                accessKeyId: "MY_ACCESS_KEY",
                secretAccessKey: "MY_SECRET_ACCESS_KEY)


            // Upload text file to the s3
            let bodyData = "hello world".data(using: .utf8)!
            let putObjectRequest =
                S3.PutObjectRequest(acl: .publicRead,
                                    bucket: bucket,
                                    contentLength: Int64(bodyData.count),
                                    key: "hello.txt",
                                    body: bodyData)
            let ret = try s3.putObject(putObjectRequest)

I looks like this:

screenshot 2018-12-13 at 11 35 47

I can't really solve it myself. I see there's some comments regarding the code:

//TODO(jmca) don't block

And:

//TODO(jmca) learn how to map response to validate and return
// a future of generic Output: AWSShape

Anyone know how this could be solved?

Publishing separate SPM Packages through Github's API

@jonnymacs @Yasumoto
Now I'm thinking how we can automate to publish separate SPM Packages(eg. swift-aws/ec2) flow.

My plan is Publishing separate SPM Packages through Github's API as described in title.

The work flow is...

  1. Updating models and running CodeGenerator
  2. Make a PR
  3. Merging
  4. Make a Tag(must follow semantic versioning) and push it to github, Then the script for publishing packages(commit, push, tagging) is executed on Travis(if the tag is followed semantic versioning)

How do you think this?

Glacier Job payload should be in JSON but it isn't

Whenever I try to send an InitiateJob() request to Glacier, it always returns the following error.

AWSError(message: "SerializationException", rawBody: "{\"code\":\"SerializationException\",\"type\":\"Client\",\"message\":\"SerializationException\"}")

The cause of this look like it is because the body of the InitiateJob() request contains the JobParameters and these should be in json. But it is coming out in this form

JobParameters(retrievalByteRange: nil, tier: nil, format: nil, selectParameters: nil, description: Optional(\"Inventory\"), inventoryRetrievalParameters: Optional(Glacier.Glacier.InventoryRetrievalJobInput(marker: nil, limit: nil, endDate: nil, startDate: nil)), outputLocation: nil, type: Optional(\"inventory-retrieval\"), archiveId: nil, sNSTopic: nil)

This looks like it could be a common issue across all AWS systems where a json body is required.

Ec2.FilterList not encoded correctly

The DescribeSecurityGroups call doesn't look like it has a properly generated request format:

16:32:34 [server] $ aws ec2 describe-security-groups --filters 'Name=group-name,Values=test-group' --generate-cli-skeleton
{
    "Filters": [
        {
            "Name": "",
            "Values": [
                ""
            ]
        }
    ],
    "GroupIds": [
        ""
    ],
    "GroupNames": [
        ""
    ],
    "DryRun": true,
    "NextToken": "",
    "MaxResults": 0
}

Then when creating this:

let filters = Ec2.FilterList(filter: [Ec2.Filter(name: "group-name", values: Ec2.ValueStringList(item: ["test-group"]))])

let request = Ec2.DescribeSecurityGroupsRequest(maxResults: nil, groupIds: nil, filters: filters, dryRun: nil, nextToken: nil, groupNames: nil)
let encoded = try JSONEncoder().encode(request)
if let json = String(data: encoded, encoding: .utf8) {
    print(json)
}
let client = Ec2()
let response = try client.describeSecurityGroups(request)

Here's what we get (along with the response when we send it to AWS:

16:32:47 [server] $ swift build && ./.build/x86_64-unknown-linux/debug/Tool
{"Filter":{"Filter":[{"Name":"group-name","Value":{"item":["test-group"]}}]}}

Fatal error: Error raised at top level: AWSSDKSwiftCore.AWSError(message: "Unhandled Error", rawBody: "<html><head><title>Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Encountered an Internal Error</h1><HR size=\"1\" noshade=\"noshade\"><p><b>type</b> Status report</p><p><b>message</b> <u>Encountered an Internal Error</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><HR size=\"1\" noshade=\"noshade\"></body></html>"): file /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/stdlib/public/core/ErrorType.swift, line 191

Incorrect stringToSign created for API calls that include query parameters without assignation

If you have a URL with a query parameter which does not assign a value, the stringToSign created during signature constructions is incorrect. AWS expects the stringToSign to still include an '=' character. For instance the string to sign for CreateMultipartUpload() which has path "/{Bucket}/{Key+}?uploads" is

POST
/test/file.pdf
uploads
host:<s3 bucket host>
x-amz-content-sha256:<sha256>
x-amz-date:<date>

when it should be

POST
/test/file.pdf
uploads=
host:<s3 bucket host>
x-amz-content-sha256:<sha256>
x-amz-date:<date>

Fatal error when connecting to DynamoDB.

Get Fatal error: Unexpectedly found nil while unwrapping an Optional val

#7 0x00000001018a2f4c in Signers.V4.signedHeaders(url:headers:method:date:bodyData:) at .build/checkouts/aws-sdk-swift-core.git--8673986503349919441/Sources/AWSSDKSwiftCore/Signers/V4.swift:96
#8 0x000000010181e60d in AWSClient.nioRequestWithSignedHeader(:) at .build/checkouts/aws-sdk-swift-core.git--8673986503349919441/Sources/AWSSDKSwiftCore/AWSClient.swift:217
#9 0x000000010181de57 in AWSClient.createNIORequestWithSignedHeader(
:) at .build/checkouts/aws-sdk-swift-core.git--8673986503349919441/Sources/AWSSDKSwiftCore/AWSClient.swift:190
#10 0x0000000101819737 in AWSClient.createNioRequest(:) at .build/checkouts/aws-sdk-swift-core.git--8673986503349919441/Sources/AWSSDKSwiftCore/AWSClient.swift:243
#11 0x000000010181d70f in AWSClient.send<A, B>(operation:path:httpMethod:input:) at .build/checkouts/aws-sdk-swift-core.git--8673986503349919441/Sources/AWSSDKSwiftCore/AWSClient.swift:171
#12 0x0000000101094273 in DynamoDB.getItem(
:) at .build/checkouts/aws-sdk-swift.git--2129101693774578373/Sources/AWSSDKSwift/Services/DynamoDB/DynamoDB_API.swift:91

code in signedHeaders(url: URL, headers: [String: String], method: String, date: Date = Date(), bodyData: Data) -> [String: String]

      var headersForSign = [
            "x-amz-content-sha256": hexEncodedBodyHash(bodyData),
            "x-amz-date": datetime,
            "Host": url.hostWithPort!, // Forced unwrap fatal error is here 
        ]

Does this work for IOS development?

Has anyone tried this SDK for IOS development? I'm developing applications running under Linux that access AWS cloud services and my wife is doing the same as IOS applications - it would be useful if we could build around a common source base!

Unable to build package

I've added aws-sdk-swift to my package.swift and am running into all sorts of errors with the Prorsum dependency. Here are a few examples (but there are dozens of similar errors):

Prorsum.git--8295785803236466221/Sources/Prorsum/HTTP/Parser/Parser.swift:4:39: Use of undeclared type 'http_errno'

Prorsum.git--8295785803236466221/Sources/Prorsum/WebSocket/Data+WebsocketCompute.swift:63:25: Ambiguous use of 'subscript'

Any thoughts would be appreciated.

Here is my package.swift:

import PackageDescription

let package = Package(
name: "AtlasCore",
products: [
.library(
name: "AtlasCore",
targets: ["AtlasCore"]
),
],
dependencies: [
.package(url: "https://github.com/swift-aws/aws-sdk-swift.git", from: "1.0.0"),
.package(url: "https://github.com/Quick/Quick.git", from: "1.0.0"),
.package(url: "https://github.com/Quick/Nimble.git", from: "7.1.0"),
],
targets: [
.target(
name: "AtlasCore",
dependencies: ["AWSSDKSwift"]),
.testTarget(
name: "AtlasCoreTests",
dependencies: ["AtlasCore", "Quick", "Nimble"]),
]
)

And here is the Package.resolved:

{
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick.git",
"state": {
"branch": null,
"revision": "b060679e70d13c3c7dcd124201b5b1b34ce6f340",
"version": "1.3.1"
}
},
{
"package": "SwiftyJSON",
"repositoryURL": "https://github.com/IBM-Swift/SwiftyJSON.git",
"state": {
"branch": null,
"revision": "693d2d28fe2f91aedf02c3754baade625fd97c46",
"version": "17.0.2"
}
}
]
},
"version": 1
}

Consider using `var` instead of `let` in a request struct

All of request models in this SDK use let for its parameters.

public struct ContainerDefinition: AWSShape {
    public let memoryReservation: Int32?
    public let portMappings: [PortMapping]?
    ...
}

But it could not change those params after initialize it.

Changing the let to var, we could build a parameter and update anytime.

var myContainer = ContainerDefinition(name: "api")
myContainer.memory = 256
let theContainer = containerDefinition

Simple Email Service - Sending HTML emails doesn't work

Hi, I'm trying to send an HTML message using Email service and I get the following error message:

malformedQueryString(Optional("Action=SendEmail&Destination.ToAddresses.member.1=
damir.sirola%40masinerija.com&Message.Body.Html.Data=%3Chtml%3E%3Cbody%3E%3Ca%20
href=%22https%3A%2F%2Fgoogle.com%22%3ETest%3C%2Fa%3E%3C%2Fbody%3E%3C%2Fhtml
%3E&Message.Subject.Data=Registration&Source=damir.sirola%40gmail.com&Version=
2010-12-01 is not valid; the value of a query string parameter may not contain 
a \'=\' delimiter"))

Here is the code I use to create email message:

let message =
    AWSSDKSwift.Email.Message(
        body: AWSSDKSwift.Email.Body(
            html: AWSSDKSwift.Email.Content(data: "<html><body><a href=\"https://google.com\">Test</a></body></html>")
        ),
        subject: AWSSDKSwift.Email.Content(
            data: "Registration"
        )
)

I tried to replace = sign with urlEncoded version, but it doesn't work (the = sign is ignored then)
I think that = sign should be encoded with rest of the message.

I managed to track the problem to AWSClient.swift file lines 263-270 where = sign in value is not encoded.

I tried to replace the code here: https://github.com/noppoMan/aws-sdk-swift-core/blob/master/Sources/AWSSDKSwiftCore/AWSClient.swift#L271
with the following quick and dirty implementation and it sends HTML emails just fine

                let characters: Characters = ["\'", "(", ")", "-", ".", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
                for key in keys {
                    
                    if let value = dict[key] {
                        
                        let k = key.percentEncoded(allowing: characters)
                        let v = String(describing: value).percentEncoded(allowing: characters)
                        queryItems.append("\(k)=\(v)")
                    }
                }

Note that I removed = and & from allowed characters

AWS S3 V4 Lifecycle policy

Hi,
I found it Today, Can I use your library to every operation with S3?

Like, put an object, delete an object?
Moreover, I want to put lifecycle policy to delete multiple objects with the same prefix. for example "a/b/c/*"
How to achieve it with your framework?
Will it work with Kitura?

I've tried to do it myself
https://stackoverflow.com/questions/52547175/swift-aws-s3-v4-put-lifecycle-configuration-calculated-signature
However, I did encounter a problem which stopped me for more than two weeks now.

Issues supplying APNs SSL certificate and private key to createPlatformApplication

This requires issue #106 to be resolved first

To get Apple Push Notifications working with the AWS SNS system you need to setup a platform application. The platform application creation requires an SSL certificate and a private key that Apple provides. You supply them as follows

    var attributes : [String : String] = [
        "PlatformCredential" : privateKey,
        "PlatformPrincipal" : SSLCertificate
        ]
    
    let createApplicationInput = SNS.CreatePlatformApplicationInput(attributes:attributes, name:applicationName, platform:"APNS_SANDBOX")
    let createApplicationResponse = try sns.createPlatformApplication(createApplicationInput)

I am providing them in pem format

-----BEGIN CERTIFICATE-----
MIIEKJHKhkjjsndfmnisudf...
-----END CERTIFICATE-----

and

-----BEGIN PRIVATE KEY-----
MIIEkjjgusdfdfjjnemn/sdfh...
-----END PRIVATE KEY-----

The call fails though with the following error
invalidParameter(message: Optional("Invalid parameter: PlatformPrincipal not valid.")). I have tried my certificate and key with the CLI and web interfaces and they both work.

Simple Email Service - Signature does not match

Hi, thanks for the great library, but I'm having an issue with Email service.
When I try to send an email I get the following error:

signatureDoesNotMatch(Optional("The request signature we calculated does not match the
signature you provided. Check your AWS Secret Access Key and signing method. Consult the
service documentation for details.

I'm using the following code to initialize the service and send the request:

        let emailService = AWSSDKSwift.Email(accessKeyId: accessKey, secretAccessKey: secretKey,
                 region: .euwest1, endpoint: "https://email.eu-west-1.amazonaws.com")
        let destination = AWSSDKSwift.Email.Destination(toAddresses: [email.to])
        let message =
            AWSSDKSwift.Email.Message(
                body: AWSSDKSwift.Email.Body(
                    text: AWSSDKSwift.Email.Content(data: "Test")
                ),
                subject: AWSSDKSwift.Email.Content(
                    data: email.subject
                )
            )
        let emailRequest = AWSSDKSwift.Email.SendEmailRequest(
            destination: destination,
            message: message,
            source: email.from
        )
        do {
            let result = try emailService.sendEmail(emailRequest)
        } catch { 
            ...
        }

Both email.to and email.from are validated emails.
I tried different access key and secret key always making sure they have AmazonSESFullAccess policy.
I haven't tried using any other service yet.

Dictionaries are not serialised correctly when the service protocol is query

When serialising dictionaries in queries they are currently being serialised as

<dictionary name>.<entry key>=<entry value>

The output should be of the form

<dictionary name>.entry.N.key=<entry key>
&<dictionary name>.entry.N.value=<entry value>

where N is the index of the key, value pair.

An example of this is SNS.createTopic() set one of the attributes and you get a MalformedInput error returned back from AWS.

I have had a look at how to resolve this. The best I've come up with so far is https://github.com/adam-fowler/aws-sdk-swift-core/blob/serialize-dictionary/Sources/AWSSDKSwiftCore/AWSShapes/Dictionary.swift. I have hand replaced some of the dictionaries with this DictionaryShape class in the SNS Shape classes and it fixes the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.