Getting Started

This page will walk you through connecting to and using a Datomic Cloud Database.


This tutorial requires:

Install Clojure

Install the AWS CLI

Install the AWS Command Line Interface. Make sure you have version 1.11.170 or later. You can test your version with:

aws --version

NOTE: Running the datomic-socks-proxy script with an earlier version of the AWS CLI will result in a generic error message and failure of the script.

Configure AWS Access Keys

If you have not done so already:

  1. Create access keys for your Datomic user
  2. Add access keys to your environment

Datomic supports the use of AWS profiles as a credentials source. Additional information about IAM Users and access keys can be found in the AWS Security Credentials documentation .

Start a SOCKS proxy

In this step you will start a SOCKS proxy from your local dev machine to a bastion host that is running in AWS. If you are developing from an EC2 instance inside the same VPC as Datomic, you can skip this step.

To start the proxy

Additional details on the SOCKS proxy script are provided in the Operations Documentation.

If you don't know your system name, the names of all running Datomic systems in your AWS account can be found with the following AWS CLI command (you can add --profile <profile-name> to run in the context of an AWS Credentials Profile):

aws ec2 describe-instances --filters "Name=tag-key,Values=datomic:tx-group" "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].[Tags[?Key==`datomic:system`].Value]' --output text

Depending on your local system settings, you may be prompted by SSH with:

The authenticity of host <bastion-server-address> can't be established.
RSA key fingerprint is <an SSH key>.
Are you sure you want to continue connecting (yes/no)?

Enter yes to continue establishing the proxy.

NOTE Your terminal will be locked to this proxy process. If you want to kill the proxy, you can either CTRL-C from this shell or kill the terminal window. To follow further steps, you must open a second terminal window.

Test Bastion Connection

See the Arcitecture page for a complete picture of how the SOCKS proxy reaches Datomic

Run the following command to test your system's ability to reach Datomic through the SOCKS proxy, replacing the environment variables with the same values you used when launching the SOCKS proxy:

export DATOMIC_SYSTEM=my-system
export DATOMIC_REGION=us-east-1

curl -x socks5h://localhost:$DATOMIC_SOCKS_PORT http://entry.$DATOMIC_SYSTEM.$

It should return:

{:s3-auth-path <bucket-name>}

An error response indicates that your Datomic system is not available at the specified port and address. Verify that your primary stack and your SOCKS proxy are running and correctly configured.

Additional common issues with proxy configuration are discussed in the troubleshooting documentation.

Congratulations! You have successfully configured a SOCKS proxy through the bastion server to allow local access to your Datomic system.

Add Client Library Dependency

The Datomic Client library is provided via Maven Central.

Clojure CLI

To use the Client library from a Clojure CLI REPL, add the following to your deps.edn dependencies map:

com.datomic/client-cloud {:mvn/version "0.8.66"}


To retrieve the Client library for a Maven project, add the following snippet inside the <dependencies> block of your pom.xml file:



To include the Client library in a Leiningen project, add the following snippet to your project.clj file:

;; in collection under :dependencies key
[com.datomic/client-cloud "0.8.66"]

Connect and Use Datomic

Create a Database

To interact with Datomic Cloud, you must first specify a system connection, with:

  • :endpoint is the URI where your system can be reached, "http://entry.<system-name>.<region>" where <system-name> is the same as the Stack Name you used to start the CloudFormation Storage Stack. This endpoint is labeled as EndpointAddress in the Cloudformation Output of the compute stack.
  • :region is the AWS region in which you've started Datomic Cloud.
  • :system is the SystemName

In your REPL, execute:

(require '[datomic.client.api :as d])

(def cfg {:server-type :ion
          :region "<your AWS Region>" ;; e.g. us-east-1
          :system "<system-name>"
          :endpoint "http://entry.<system-name>.<region>"
          :proxy-port <local-port for SSH tunnel to bastion>})

(def client (d/client cfg))

Given a system, you can use the admin API to create a new database.

(d/create-database client {:db-name "movies"})

Now you're ready to connect to your newly created database:

(def conn (d/connect client {:db-name "movies"}))

The next step will be to define some schema for your new database.

Transact Schema

Define the following small schema for a database about movies:

(def movie-schema [{:db/ident :movie/title
                    :db/valueType :db.type/string
                    :db/cardinality :db.cardinality/one
                    :db/doc "The title of the movie"}

                   {:db/ident :movie/genre
                    :db/valueType :db.type/string
                    :db/cardinality :db.cardinality/one
                    :db/doc "The genre of the movie"}

                   {:db/ident :movie/release-year
                    :db/valueType :db.type/long
                    :db/cardinality :db.cardinality/one
                    :db/doc "The year the movie was released in theaters"}])

Now transact the schema:

(d/transact conn {:tx-data movie-schema})

You should get back a response like the following:

{:db-before ..., 
 :db-after ..., 
 :tx-data [...], ;; data added to the database
 :tempids {}}

Transact Data

Now you can define some movies to add to the database:

(def first-movies [{:movie/title "The Goonies"
                    :movie/genre "action/adventure"
                    :movie/release-year 1985}
                   {:movie/title "Commando"
                    :movie/genre "action/adventure"
                    :movie/release-year 1985}
                   {:movie/title "Repo Man"
                    :movie/genre "punk dystopia"
                    :movie/release-year 1984}])
=> #'user/first-movies

Transact the movies into the database:

(d/transact conn {:tx-data first-movies})
=> {:db-before ... 
    :db-after ...
    :tx-data [...], 
    :tempids {}}


Get a current value for the database:

(def db (d/db conn))  

Now create a query for all movie titles:

(def all-titles-q '[:find ?movie-title 
                    :where [_ :movie/title ?movie-title]])

And execute the query with the value of the database:

(d/q all-titles-q db)
=> [["Commando"] ["The Goonies"] ["Repo Man"]]

Delete a Database

When you are done with this tutorial, you can use delete-database to delete the movies database:

(d/delete-database client {:db-name "movies"})


If you encounter issues connecting to or using your system, review the common client errors described in the troubleshooting documentation.

Next Steps

You have successfully connected to and used Datomic. For a more in depth exploration, see the Tutorial.

The Client API Documentation provides more details on the Datomic Client API itself.