Fork me on GitHub
#datomic
<
2020-01-30
>
jcf15:01:22

Hello everyone! I'm kicking the tyres on Datomic Cloud, and have run into a problem that I think might be a bug. I have a working SOCKS proxy and can curl -x "socks5h://... to verify the connection is healthy. Now I'm trying to create a database but I'm getting an error about there not being an AWS profile with the name I've specified in my config:

(def cfg
  {:server-type   :ion
   :region        "eu-west-1"
   :system        "<REDACTED>"
   :creds-profile "dev"
   :endpoint      ".<REDACTED>."
   :proxy-port    8182})
With that config I can create a client without issue, and can invoke the call to datomic.client.api/create-database but that's where this exception is thrown:
1. Unhandled clojure.lang.ExceptionInfo
   No AWS profile named 'dev'
   #:cognitect.anomalies{:category :cognitect.anomalies/fault,
                         :message "No AWS profile named 'dev'"}
                 async.clj:   58  datomic.client.api.async/ares
                 async.clj:   54  datomic.client.api.async/ares
                  sync.clj:   73  datomic.client.api.sync.Client/create_database
                   api.clj:  144  datomic.client.api/create-database
                   api.clj:  135  datomic.client.api/create-database

jcf15:01:41

I know that profile does exist. I can use it via the CLI (e.g. aws --profile dev s3 ls). I'm using STS to access an organisation within my account, and I think this might be where the problem comes from.

jcf15:01:13

Can the client library work across orgs via STS or is this unsupported?

ghadi15:01:15

@jcf you're deploying an ion?

ghadi15:01:27

or testing locally on your laptop?

jcf15:01:55

@ghadi not yet. Just trying to create a database from my local machine. I thought the client could create DBs with Datomic Cloud, but maybe not?

ghadi15:01:37

You can. But server type needs to be :client when local going over proxy

jcf15:01:15

1. Caused by clojure.lang.ExceptionInfo
   :server-type must be one of :cloud, :local, :peer-client, or :peer-server
   #:cognitect.anomalies{:category :cognitect.anomalies/incorrect,
                         :message
                         ":server-type must be one of :cloud, :local, :peer-client, or :peer-server"}

jcf15:01:21

Peer client?

ghadi15:01:39

:cloud, sorry

ghadi15:01:46

but wait --

jcf15:01:57

That's good because using :peer-client gave me this:

1. Caused by .FileNotFoundException
   Could not locate datomic/peer_client__init.class, datomic/peer_client.clj or
   datomic/peer_client.cljc on classpath. Please check that namespaces with
   dashes use underscores in the Clojure file name.
😄

ghadi15:01:09

what dependency are you using in your deps/project.clj ?

jcf15:01:19

:deps
 {com.cognitect/anomalies  {:mvn/version "0.1.12"}
  com.datomic/client-cloud {:mvn/version "0.8.81"}
  com.datomic/ion          {:mvn/version "0.9.35"}
  org.clojure/clojure      {:mvn/version "1.10.1"}
  org.clojure/data.json    {:mvn/version "0.2.7"}}

jcf15:01:42

I'm following the tutorial to get connected and get the client running locally.

ghadi15:01:03

link to tutorial?

jcf15:01:40

I've gone through a few pages to get to this point.

jcf15:01:37

Prerequestites to then get to https://docs.datomic.com/cloud/getting-started/start-system.html. Then on to https://docs.datomic.com/cloud/getting-started/get-connected.html. Now I'm doing the client API cloud tutorial above.

jcf15:01:55

@ghadi I'm pretty sure @daemianmack and Joe ran into this same problem when we were trying to pull together a Datomic Cloud demo on a recent consulting gig. There was some workaround they needed to get profiles working across AWS orgs.

jcf15:01:15

I've got the same setup where I have a root AWS account with IAM users. Those users assume an admin role in sub-orgs via profiles. It works via the AWS CLI but I think maybe the Java SDK doesn't work the same way.

jcf15:01:18

I'm crawling through GitHub issues now. 😅

jcf15:01:30

This has been open for a couple of years and appears unresolved: https://github.com/aws/aws-sdk-java/issues/803

jcf15:01:12

No AWS profile named 'dev' is a really odd error. It looks like the profile isn't being found at all as opposed to not having the right permissions etc.

daemianmack15:01:06

heya @jcf! how’s things?

jcf15:01:30

Hey, @daemianmack! Really good thanks! Hope you're well. 🙂

daemianmack15:01:03

i don’t quite understand why you’d get that profile error at that point in the sequence, instead of earlier, but we eventually settled on aws-mfa to handle that piece of things — https://github.com/broamski/aws-mfa

jcf15:01:28

Oh, I haven't gotten to MFA yet. That's gonna be fun! 😄

daemianmack15:01:50

yeee…. essss.

jcf15:01:12

Whatever happened to days of an API key over HTTP?!

jcf15:01:57

Creating a custom credential provider's going to mean some lifecycle management from the looks of it. I have to stop the provider. Hmm. This is surely too fiddly to be the right way of connecting things.

jcf15:01:57

Ahh, shucks! Looks like Datomic Client doesn't use aws-api. I think I'm going to park this for today. Why I'm getting told I don't have a profile that I know exists I'm not sure but I'll dig in more soon.

jcf15:01:12

Thanks for the help, @ghadi @daemianmack! Much appreciated. 🙂

daemianmack15:01:11

let us know what you find out @jcf!

👍 4
jcf15:01:32

Will do! 🙂

kenny19:01:36

Does Datomic not allow you to divide two numbers in a query and get a number that is between 0-1?

kenny19:01:17

e.g. [(/ ?connected-mins ?reported-mins) ?percent-connected] ?percent-connected is always 0 for some reason.

ghadi19:01:04

call (/ x y) in a repl and check the output

kenny19:01:50

Just a regular result?

(/ 5352 13380)
=> 2/5

kenny19:01:59

Huh... https://docs.datomic.com/cloud/query/query-data-reference.html#built-in-functions > Datomic's / operator is similar to Clojure's / in terms of promotion and contagion with a notable exception: Datomic's / operator does not return a clojure.lang.Ratio to callers. Instead, it returns a quotient as per quot. I guess I have to store these attributes as doubles to be able to do division on them?

kenny20:01:04

This appears to work

[(double ?connected-mins) ?connected-mins-dbl]
[(double ?reported-mins) ?reported-mins-dbl]
[(/ ?connected-mins-dbl ?reported-mins-dbl) ?percent-connected]

ghadi20:01:30

yeah you need coerce one of the arguments to double @kenny

4