Fork me on GitHub
#aws
<
2020-05-25
>
Empperi18:05:52

Hi. I have a problem with Amazonica and Localstack

Empperi18:05:29

No matter what I do, I cannot get endpoint configuration into place in such a way that AWS SDK or Amazonica would like it

Empperi18:05:00

Any tips on how to do this?

Empperi18:05:52

I've tried all the usual (s3/list-buckets {:endpoint ""}) stuff already

Empperi18:05:27

All I get is

java.lang.IllegalStateException: S3 client with invalid S3 endpoint configured: my-localstack-domain:4566

Empperi18:05:05

This happens at

com.amazonaws.services.s3.AmazonS3Client.getRegion(AmazonS3Client.java:4590)

Empperi18:05:44

Which makes sense since Amazonica is leaving region as nil on purpose https://github.com/mcohen01/amazonica/blob/master/src/amazonica/core.clj#L162

Empperi18:05:43

I however cannot create that EndpointConfiguration object myself and pass it in since Amazonica is expecting a string

Empperi19:05:02

Managed to hack past that with this:

(with-redefs [amazonica.core/build-client (constantly
                                            (-> (AmazonS3ClientBuilder/standard)
                                                (.enablePathStyleAccess)
                                                (.withEndpointConfiguration (AwsClientBuilder$EndpointConfiguration.
                                                                              (format "" host port)
                                                                              "eu-central-1"))
                                                (.build)))]
  (s3/list-buckets))

Empperi19:05:19

Definitely not pretty but at least now I get requests to localstack