Skip to content

Instantly share code, notes, and snippets.

@jzwiep
jzwiep / docker_compose_assume_iam_role.sh
Created July 27, 2018 18:21
Assume a specific IAM role with a container via docker-compose
#!/bin/bash
# Assume the role using locally configured AWS credentials, then pass the assumed role to the container via environment
# variables!
ASSUMED_ROLE=$(aws sts assume-role \
--role-arn "arn:aws:iam::000000000000:role/our-role-to-assume" \
--role-session-name "session_name" \
--output text)
@jzwiep
jzwiep / docker_compose_exec.sh
Last active June 29, 2018 17:23
Setting proper shell width for 'docker-compose exec'
docker-compose exec -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) <container> <command>
@jzwiep
jzwiep / load_ssm_params.sh
Last active February 2, 2018 05:04
Load all SSM parameters on a path into your environment
PARAMS_LIST=$(aws ssm get-parameters-by-path \
--path "/var/path/" \
--recursive \
--query 'Parameters[*].[Name, Value]' \
--output text \
--with-decryption)
# "/var/path/VARNAME variable_value" --> "export VARNAME=variable_value"
EXPORT_STATEMENTS=$(echo "$PARAMS_LIST" | awk '{ sub(".*/", "", $1); printf("export %s=\"%s\"\n", $1, $2) }')