Skip to content

Instantly share code, notes, and snippets.

@limed
Created February 9, 2018 18:54
Show Gist options
  • Select an option

  • Save limed/3180ee11ee82f7d50405d373c0ebfa8f to your computer and use it in GitHub Desktop.

Select an option

Save limed/3180ee11ee82f7d50405d373c0ebfa8f to your computer and use it in GitHub Desktop.
function aws-vault() {
local aws_vault_cmd=$(which aws-vault)
if [ -z "${aws_vault_cmd}" ]; then
echo "aws-vault is not on your path you do not have it installed"
exit 1
fi
case "$1" in
exec)
local action=$1
shift 1
local profile=$1
shift 1
local options="--assume-role-ttl=1h --session-ttl=4h"
#${aws_vault_cmd} ${action} ${profile} ${options} -- $@
${aws_vault_cmd} ${action} ${profile} ${options} $@
;;
*)
${aws_vault_cmd} $@
;;
esac
}
# Nubis docker specific function
function nubis-build() {
if [ -z "${1}" ]; then echo "Usage: $FUNCNAME <docker image name>"; exit 1; fi
local docker_image=$1
shift 1
local args=$@
echo "Running on profile: $(cat ~/.docker.env | grep AWS_VAULT | cut -f2 -d "=")"
docker_cmd="docker run -u "${UID}:$(id -g)" --interactive --tty --env-file $(echo ~)/.docker.env -v "$PWD:/nubis/data" -e "GIT_COMMIT_SHA=$(git rev-parse HEAD)""
${docker_cmd} ${docker_image} ${args} build
# FIXME: won't be able to do other things like debug
#if [ ! -z "${args}" ]; then
# ${docker_cmd} ${docker_image} ${args} build
#else
# ${docker_cmd} ${docker_image}
#fi
}
# untested :)
function nubis-deploy() {
if [ -z "${1}" ]; then echo "Usage: $FUNCNAME <docker image name>"; exit 1; fi
local docker_image=$1
shift 1
local args=$@
echo "Running on profile: $(cat ~/.docker.env | grep AWS_VAULT | cut -f2 -d "=")"
docker run --interactive --tty --env-file $(echo ~)/.docker.env -v $PWD:/nubis/data ${docker_image} ${args}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment