cognitect-labs / aws-api

AWS, data driven

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide user-friendly error when S3 bucket is in a different region

holyjak opened this issue · comments

Hello! It would be awesome if aws-api provided a user-friendly error for the problem described here https://github.com/cognitect-labs/aws-api#invalid-location-header-null

I imagine there is a number of users that wasted lot of time troubleshooting this, who did not thought of checking the Readme for the error. So catching it and returning something easier to understand (such as "The target bucket is in a different region then the client's eu-west-1. Create a client for the same region.").

It would be better if AWS got their act together and returned a sensible error but I am afraid they are not as flexible as we need :)

users that wasted lot of time ...

👍

This issue cropped up for me during fetching of s3 maven dependencies with deps.edn and clojure cli.

We created an s3 bucket for a private maven repository in eu-west-1 and updated the :mvn/repos value to include this s3 url. We also have a dependency on datomic and cognitect artifacts, which are on an s3 bucket in us-east-1. I think there is some kind of conflict here when s3 maven repos are not in the same region, when downloading artifacts with deps.edn.

Workaround for us was to create a new bucket in us-east-1.

0.8.64 upgrades to the latest com.cognitect/http-client, which includes headers and status in the anomaly:

{:status 301,
 :headers {"x-amz-bucket-region" "us-east-1"}}

So now you can detect the 301 and then re-send the request to the correct region. We'll probably automate eventually, but, for now, at least you have the information you need to take corrective action programmatically.