amazonica
amazonica copied to clipboard
Suggestion: with-region
There is an obvious way to spell with-region
in 3rd party code:
(defmacro with-region
[region & body]
`(amazonica.core/with-credential
{:endpoint (name ~region)}
~@body))
However, this has a subtle bug: if you nest with-credential calls, with-region will override previously set credentials. Arguably, the real thing to do here is to set credentials via env vars or something so the problem doesn't happen, but, alternatively:
(defmacro with-region
[region & body]
`(amazonica.core/with-credential
(assoc @#'amazonica.core/*credentials* :endpoint (name ~region))
~@body))
You can do this in third-party code, but only with the weird @#'
visibility-bypass hack.