janus/secrets
A component for managing application secrets with a layered lookup chain and AWS Secrets Manager integration.
Setup
Add the dependency:
;; deps.edn
{janus/secrets {:mvn/version "..."}}
Require the API namespace:
(require '[janus.secrets.api :as secrets])
Lookup Chain
When resolving a secret via secrets/get, the following sources are checked in order.
The first non-nil value wins:
-
Java system property
-
Environment variable
-
.envfile (same key as the env var) -
AWS Secrets Manager
Naming Conventions
A secret id is a qualified keyword, e.g. :cloudflare/api-token.
Each tier derives its key from the id automatically:
| Tier | Pattern | Example |
|---|---|---|
System property |
|
|
Environment variable |
|
|
|
same as env var |
|
AWS Secrets Manager |
|
|
API Reference
get
(secrets/get :cloudflare/api-token) ;; => "sk-..." or nil
Looks up a single secret by qualified keyword id using the lookup chain above.
Returns the string value or nil.
Throws on AWS errors other than not-found.
fetch-remote
(secrets/fetch-remote [:cloudflare/api-token :db/password])
;; => {:cloudflare/api-token "sk-..." :db/password "hunter2"}
Batch-fetches secrets from AWS for a seq of qualified keyword ids.
Returns a {kw value} map, or an anomaly.
CLI Tool
AWS Authentication
You must be authenticated with AWS before using remote operations.
# Log in via SSO
aws sso login
# Or specify a profile
AWS_PROFILE=my-profile clojure -Т:secrets fetch :secrets '[:cloudflare/api-token]'
The standard AWS credential chain applies: environment variables, profiles, IAM roles, etc.