Dynq is a DynamoDB client intended to make querying and sourcing environment variables from the commandline very easy.
APACHE-2.0 License
dynq
, short for DynamoDB Query, is a commandline client for pulling data out of DynamoDB. Its primary function is to
expose a minimal API for querying DynamoDB in a key=value
format and then return data that can be directly piped or
sourced into a shell script's environment. For example:
dynq --table-name deployment --key-value environment=gozer-dev
might return the following:
environment=gozer-dev
db_host="temple.of.gozer"
run_script="zuul --find-keymaster vinz"
If dynq
fails in any way, it should raise a non-zero exit code on termination.
key=value
formatdynq
is just a single binary that you can drop anywhere you feel like on a *nix based system (sorry Windows, maybe
it works with Cygwin...). As long as you have Python 2.6 or above installed, you can install it with:
sudo curl -o /usr/local/bin/dynq -L "https://github.com/rholder/dynq/releases/download/v0.2.0/dynq" && \
sudo chmod +x /usr/local/bin/dynq
Here's a minimal example of sourcing directly into the current shell from DynamoDB:
#!/usr/bin/env bash
set -o nounset
# source the content of all of our key/values
source <(dynq --table-name deployment --key-value environment=new_york)
# do something with the variables
echo ${CROSS_STREAMS}
Here's a more debuggable example of sourcing some environment variables from DynamoDB into a temporary file first:
#!/usr/bin/env bash
set -o nounset
# write out the content of all of our key/values to a tmp file
DYNQ_SOURCE=$(mktemp)
dynq --table-name deployment --key-value environment=new_york > ${DYNQ_SOURCE}
# bring in all of the fetched variables to the current shell
source ${DYNQ_SOURCE}
# do something with the variables
echo ${CROSS_STREAMS}
# clean up when all is well at the end
rm ${DYNQ_SOURCE}
The dynq
project is released under version 2.0 of the
Apache License.