Giter Site home page Giter Site logo

aws's Introduction

AWS

Swift Version Vapor Version Circle CI codebeat badge codecov Readme Score GitHub license

This package makes it easy to use AWS resources from Swift.

๐Ÿ“ฆ Installation

Update your Package.swift file.

.Package(url: "https://github.com/nodes-vapor/aws.git", majorVersion: 1)

Getting started ๐Ÿš€

Currently the following AWS Services are available:

  • EC2
  • S3

If you need other resources you can use Raw call, to call the AWS API directly.

EC2

Describe instances

do {
    let instances = try EC2(
        accessKey: "my-key", 
        secretKey: "my-secret", 
        region: "my-region"
    ).describeInstances()
} catch {

}

S3

Upload a file to S3

do {
    try S3(
        accessKey: "my-key", 
        secretKey: "my-secret", 
        region: "my-region", 
        bucket: "my-s3-bucket"
    ).uploadFile("/path/to/local/file", "/folder/in/s3/bucket")
} catch {

}

Raw call

If you need a resource not made in one of the functions, you can use the system to call the AWS API directly.

Describe instances example

do {
    return try CallAWS().call(
        method: "GET", 
        service: "ec2", 
        host: "ec2.amazonaws.com", 
        region: "my-region", 
        baseURL: "https://ec2.amazonaws.com", 
        key: "my-key", 
        secret: "my-secret", 
        requestParam: "Action=DescribeInstances"
    )
} catch {

}

๐Ÿ“ƒ Development

If you want to improve this, you'll need to make sure you're making a copy of OpenSSL available to swift build and the toolchain. If you use Xcode, something like the following after brew install openssl will work:

swift package -Xswiftc -I/usr/local/Cellar/openssl/1.0.2j/include -Xlinker -L/usr/local/Cellar/openssl/1.0.2j/lib/ generate-xcodeproj

๐Ÿ† Credits

This package is developed and maintained by the Vapor team at Nodes. The package owner for this project is Brett.

๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license

aws's People

Contributors

brettrtoomey avatar cheeteur avatar joscdk avatar loganwright avatar proggeramlug avatar steffendsommer avatar valen90 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws's Issues

Sign function should return headers passed to it

I kept running into issues with the signature not matching the one generated by AWS. The problem turned out to be missing headers passed to the sign function. This resolved the issue:

var signedHeaders = try signer.sign(payload: Payload.bytes(parameterString.bytes), method: .post, path: "/", headers: ["content-type": "application/x-www-form-urlencoded; charset=utf-8"])
signedHeaders[.contentType] = "application/x-www-form-urlencoded; charset=utf-8" // solved issue

I think the sign function should return the headers that are passed to it. What do you guys think?

Amazon Version 4 Test Suite

Required tests to be fully compliant:

Get

  • Unreserved
  • UTF-8
  • Vanilla
  • Vanilla query
  • Vanilla empty query key
  • Vanilla query unreserved
  • Vanilla UTF-8 query

Post

  • Vanilla
  • Vanilla empty query value
  • Vanilla query non unreserved

Normalize path**

  • Normalize path
  • Get relative
  • Get relative relative
  • Get slash
  • Get slash dot slash
  • Get slash pointless dot
  • Get slashes
  • Get spaces

Note: There are more test cases, but they don't pertain to us as they're testing valid key/values for queries.

**: These tests don't apply to S3 signing; an S3 url should not be normalized.

Build error

Trying to build a project that includes this package throws this error:

Cloning https://github.com/nodes-vapor/aws.git
error: The dependency graph could not be satisfied. The package (https://github.com/nodes-vapor/aws.git) with version tag in range (1.0.0..<1.9223372036854775807.9223372036854775807) is not found. Found tags ([0.0.0, 0.1.0])

Query and Header sorting

Query should be a dictionary type not a string. Query keys need to be sorted and checked for duplicates.

Get

  • Header key case
  • Header key sort

Post

  • Header key case
  • Header key sort
  • Header value case

Using Region enum

Shouldn't we be able to use the Region enum, as it's marked as public?

Unknown service error

Im receiving Socket failed with code 0 ("Success") [ipAddressValidationFailed("Name or service not known")]

let s3 = S3(host:"bucket.s3.amazonaws.com", accessKey: accessKey, secretKey: secretKey, region: .usEast1)
try s3.upload(bytes:file.part.body, path:filePath, access:.privateAccess)

Vapor percent encoder opt out

Submit to PR allowing client to opt out of percent encoding. Clients encoder isn't as sensitive as amazon requires so it causes problems with spaces and dashes.

AWS Security Token Service

Add support for AWS STS temporary security credentials

Amazon Version 4 Test Suite tests

Post

  • STS token

Documentation is out of date

The supplied documentation for submitting to S3 does not reflect that of the S3 module.

i.e. init:
The documented:
S3( accessKey: "my-key", secretKey: "my-secret", region: "my-region", bucket: "my-s3-bucket")
The actual:
S3(host: "foo", accessKey: "bar", secretKey: "bar", region: .usWest2)

i.e. upload:
The documented:
.uploadFile("/path/to/local/file", "/folder/in/s3/bucket")

The actual:
upload(bytes: [UInt8(1)], path: "f", access: .authenticatedRead)

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.