Skip to content

Instantly share code, notes, and snippets.

@quanticle
Created February 14, 2019 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quanticle/7655a80d12f90df191f5be36963f0353 to your computer and use it in GitHub Desktop.
Save quanticle/7655a80d12f90df191f5be36963f0353 to your computer and use it in GitHub Desktop.
2019-02-13 Clojure MN Meetup

AWS API Library from Cognitect: cognitect-labs/aws-api

  • Authentication
  • S3 User
  • IAM user
  • Operations
  • Documentation
  • AWS SDKs often include extra functionality that's not in the library itself

Why?

  • Clojure-native library as opposed to Amazonica, which maps the Java AWS library into Clojure
  • Outgrowth of datomic cloud – need a data-driven AWS library
  • You don't need to use as many Java-isms (don't need to create maps and interface with a builder)
  • Use if you want to easily explore the different AWS endpoints without having to look at docs and intuiting functions
  • Downsides – need to make your own helper libraries
  • Smaller than Amazonica library; better for AWS Lambda functions
    • More modular

Concepts

  • API library has the concept of clients

Namespaces

  • In your namespace, just pull in client.api
  • Evan also made an iam and s3 namespace to simplify invocation

Deps

  • 2 primary dependencies
    • com.cognitect.aws.api
    • com.cognitect.aws.endpoints
  • Then every service has its own specific namespace (s3, iam, etc)

Credentials

  • API finds credentials just like other SDKs

How to make a call to a service

(aws/invoke client {map})

Authentication

  • Ordinarily uses your keys, just like AWS CLI
  • Can create new secret keys
  • basic-credentials-provider (\rightarrow) allows you to use other keys, possibly keys created on the fly
  • Can use multiple sets of creds in the same session
  • Creating a user and giving the user permissions are separate actions
  • Create the user first, then add them to a group
  • When you invoke an AWS operation, the first argument is always the client which has the credentials that you want to use

Conventions

  • lowercase keywords are library specific
  • PascalCase keywoards are AWS specific

Docs

(aws/doc <client> <function>)

S3

  • S3 takes in a byte array – need to convert your stream into a stream of bytes or read a byte array

Other notes

  • This seems more fun than terraform
  • Almost better than the default AWS CLI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment