Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    tachyonics
    @tachyonics
    Welcome to the new community for the SmokeFramework and its supporting libraries SmokeHTTP, SmokeAWS, SmokeAWSCredentials and SmokeDynamoDB!
    tachyonics
    @tachyonics
    Hi all! We have just made available two new repositories: https://github.com/amzn/smoke-aws-generate which provides the code generator for the SmokeAWS library and https://github.com/amzn/service-model-swift-code-generate which provides the underlying service model code generation framework. Let me know if you have any questions!
    We also have two additional repositories soon to be released: a library that sits on top of these two code generation packages to build applications for the SmokeFramework and a repository of SmokeFramework examples.
    Dillan Laughlin
    @dillan
    Are there any examples of using S3 with SmokeAWS?
    Kazunobu Tasaka
    @tasanobu
    @dillan I posted a sample code on my gist. Hope it would be helpful.
    https://gist.github.com/tasanobu/539f369ea37963e5a343b71d5050b410
    Dillan Laughlin
    @dillan
    @tasanobu Thank you!
    Kazunobu Tasaka
    @tasanobu
    No problem 😄
    Dillan Laughlin
    @dillan
    @tasanobu I'm trying your S3 gist against the swift_5_nio_2 branch. When I run it with the AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID environment variables I run into the following issue in my local dev environment: info: credentialsProvider=AwsContainer 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' environment variable not specified. Rotating credentials not available.
    Dillan Laughlin
    @dillan
    From what I've read, AWS_CONTAINER_CREDENTIALS_RELATIVE_URI seems to be for ECS. How are you handling this situation?
    Dillan Laughlin
    @dillan

    I tried just supplying my own CredentialProvder object with the key and secret. I get a different error though.

    failed: The operation couldn’t be completed. (SmokeHTTPClient.HTTPClientError error 1.)

    looking in the debugger, the error says this under the hood...

    The request signature we calculated does not match the signature you provided. Check your key and signing method.

    marwey
    @marwey
    @dillan You should be able to retrieve a valid credentials provider by calling AwsContainerRotatingCredentialsProvider.get(). Make sure you have set the environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
    From where do you run this? Within Xcode or from the command line?
    Dillan Laughlin
    @dillan
    @marwey Correct. I'm using code very similar to the gist from @tasanobu, including a call to let credentialProvider: CredentialsProvider! = AwsContainerRotatingCredentialsProvider.get() and setting both environment variables. I'm running from within Xcode.
    marwey
    @marwey
    @dillan excellent. Can you please verify that the environment variables are set in the Xcode schema of your project as well? It should look similiar as in the image below.
    Also, you might want to replace the print statement of the error with something like this print("Failed with error: \(err)”). This prints the full structure of the error object - not just the localized message.
    marwey
    @marwey
    image.png
    Dillan Laughlin
    @dillan
    @marwey: Correct, the environment variables are both set on the Scheme just like in your screenshot with my own ID and Key values. The additional log information from the error reads:
    2019-09-09T10:04:48-0500 info: credentialsProvider=AwsContainer 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' environment variable not specified. Rotating credentials not available.
    Failed with error: HTTPClientError(responseCode: 400, cause: S3Model.S3CodingError.unrecognizedError("SignatureDoesNotMatch", Optional("The request signature we calculated does not match the signature you provided. Check your key and signing method.")))
    Perhaps is AWS generating keys that include characters that are't accepted by smoke?
    marwey
    @marwey
    Thank you, @dillan Could you quickly test in the macOS terminal if the credentials you are providing do work? If you could export the credentials like èxport AWS_ACCESS_KEY_ID=xxxx``` and ```AWS_SECRET_ACCESS_KEY=xxxxx``` and then runàws s3 ls``` . This should list your buckets?
    Dillan Laughlin
    @dillan
    @marwey running aws s3 ls on the command line produces a list of all of my S3 buckets as expected.
    marwey
    @marwey
    @dillan well, this is good - so we know the principal communication works! Could you share your code so I can run it on my machine?
    Dillan Laughlin
    @dillan
    @marwey:
    import SmokeAWSCredentials
    import SmokeAWSCore
    import S3Client
    import S3Model
    import SmokeHTTPClient
    import Logging
    
    struct InvocationReporting: SmokeAWSInvocationReporting {
        let logger: Logging.Logger = Logging.Logger(label: "SmokeTesting")
    }
    
    func fetchBucketList() {
        let reporting = InvocationReporting()
        let credentialProvider: CredentialsProvider! = AwsContainerRotatingCredentialsProvider.get()
        let client = AWSS3Client(credentialsProvider: credentialProvider, awsRegion: .us_east_1)
        do {
            let response = try client.listBucketsSync(reporting: reporting)
            print("succeeded: \(response)")
        } catch let error {
            print("Failed with error: \(error)")
        }
    }
    Dillan Laughlin
    @dillan
    @marwey any chance you'd share your sample so I can look for differences?
    marwey
    @marwey
    @dillan Thank you for the code example. I simplified it a bit and was able to run it successfully on my machine
    import SmokeAWSCredentials
    import SmokeAWSCore
    import S3Client
    import S3Model
    import SmokeHTTPClient
    import Logging
    
    let credentialProvider: CredentialsProvider! = AwsContainerRotatingCredentialsProvider.get()
    let client = AWSS3Client(credentialsProvider: credentialProvider, awsRegion: .us_east_1)
    do {
        let response = try client.listBucketsSync()
        print("succeeded: \(response)")
    } catch let error {
        print("Failed with error: \(error)")
    }
    Dillan Laughlin
    @dillan
    @marwey Which branch are you building against? I'm trying to build against the swift_5_nio_2 branch since I have other dependencies that use Swift 5 and NIO 2. The swift_5_nio_2 branch code requires the InvocationReporting. @tachyonics Do you happen to have an S3 sample that exercises the swift_5_nio_2 branch?
    marwey
    @marwey
    @dillan yes, that is correct. In the swift_5_nio_2 branch the code above fails with Failed with error: HTTPClientError(responseCode: 400, cause: S3Model.S3CodingError.unrecognizedError("SignatureDoesNotMatch", Optional("The request signature we calculated does not match the signature you provided. Check your key and signing method.")))
    Dillan Laughlin
    @dillan
    Dang. Ok, well I'm glad I'm not the only one then. I guess I'll need to hold off until this issue is resolved.
    marwey
    @marwey
    Yes, exactly. I am sure @tachyonics will soon have a look at it too.
    Dillan Laughlin
    @dillan
    I added some notes to the issue for swift 5 and nio 2 on github. amzn/smoke-aws#17
    tachyonics
    @tachyonics
    Thanks @dillan for all your investigation! Sorry for the delayed rely; I have been really sick this past week and am only getting back on my feet
    In Sources/SmokeAWSHttp/String+hmac.swift and Sources/SmokeAWSHttp/sha256Extensions.swift. It should be fairly easy to debug by enabling both the old and new code and comparing to determine what is doing something different.
    I will try to get to do that but it will likely be Monday
    tachyonics
    @tachyonics
    @dillan @marwey I think I have identified the issue and have pushed a fix to the swift_5_nio_2 branch. If you would be able to verify the change with your calls to S3 that would be great!
    marwey
    @marwey
    Excellent, @tachyonics ! I will give it a try as soon as my build continues fetching packages from GitHub. It just got stuck ;-(
    Dillan Laughlin
    @dillan
    @tachyonics Thanks! I gave it a quick try and I'm getting further. However, when I check the list of buckets using the code above the ListBucketsOutput has one bucket object with a nil creation date and a nil bucket name. I would have expected to see two buckets listed. On a better note, ListBucketsOutput appears to be populating the owner attribute correctly.
    marwey
    @marwey
    Yes, I can confirm this. Same behaviour on my side. However this is inline to what the output is when I run above code snipet on the master branch. So this error is not related to the swift-nio-2 branch. @dillan do you see this as well or does master work for you?