Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to local dynamo DB instance #59

Closed
dannyfreeman opened this issue Feb 20, 2019 · 3 comments
Closed

Connect to local dynamo DB instance #59

dannyfreeman opened this issue Feb 20, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@dannyfreeman
Copy link

dannyfreeman commented Feb 20, 2019

I would like the ability to connect to amazon's local dynamoDB instance that is used for running and testing locally. See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html

After getting the dynamo DB instance running on my machine, I try to use the provided endpoint override provided like so:

(def ddb (aws/client {:api :dynamodb
                      :endpoint-override "localhost:8000"}))

This give me an error where I'm unable to connect because endpoint-override does not expect a port number.

{ :cognitect.anomalies/category :cognitect.anomalies/fault, :cognitect.anomalies/message "Malformed IPv6 address at index 8: http://[localhost:3000]:443", :cognitect.http-client/throwable java.lang.IllegalArgumentException: Malformed IPv6 address at index 8: http://[localhost:3000]:443, :body  }

To mitigate this I can change the local docker container to listen on port 443 like this library expects (no big deal),and not specify the port on the :endpoint-override

(def ddb (aws/client {:api :dynamodb
                      :endpoint-override "localhost"}))

This yeilds an SSL error, since the local dynamoDB image provided by amazon does not support SSL. Their examples show using a plain http connection.

{ :cognitect.anomalies/category :cognitect.anomalies/fault, :cognitect.anomalies/message "Unrecognized SSL message, plaintext connection?", :cognitect.http-client/throwable javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?, :body  }

Some relevant system info:
I've tried running dyanmo DB with amazon's provided jar file. I also tried it with docker (to override the default port).

My clojure dependencies for this project are

[org.clojure/clojure "1.10.0"]
[com.cognitect.aws/api "0.8.253"]
[com.cognitect.aws/endpoints "1.1.11.490"]
[com.cognitect.aws/dynamodb "697.2.391.0"]

I'm not sure what the best solution is, but from a conversation on the aws channel in clojurians slack, it was suggest that providing an option to not use HTTPS may be an answer. I'd be willing to help implement this, or whatever other solution seems best if yall are willing to consider it.

Thanks!

@dchelimsky dchelimsky added the enhancement New feature or request label Feb 20, 2019
@thegeez
Copy link

thegeez commented Mar 15, 2019

I run dynamodb local on localhost:3333 and can connect using this:

(defmethod cognitect.aws.interceptors/modify-http-request "dynamodb" [service op-map http-request]
  (-> http-request
      (assoc :scheme :http
             :server-port 3333
             :server-name "localhost")
      (assoc-in [:headers "host"] "localhost:3333")))```

@dchelimsky
Copy link
Contributor

@thegeez just FYI that that namespace is explicitly called out as "Impl, don't call directly." and intentionally missing from API docs.

We're thinking through a more comprehensive solution for this and some other related issues, but no guarantee that this code doesn't change before that arrives.

dchelimsky added a commit that referenced this issue Mar 26, 2019
@dchelimsky
Copy link
Contributor

:endpoint-override map added in 0.8.280. You can supply :protocol, :hostname, and :port.

scottbale added a commit that referenced this issue Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants