Skip to content

Instantly share code, notes, and snippets.

View dfevre's full-sized avatar

David Fevre dfevre

View GitHub Profile
@dfevre
dfevre / iam-assume-role.sh
Created May 25, 2017 03:14 — forked from ambakshi/iam-assume-role.sh
Assume an IAM role. An interesting way of doing IAM roles is to give the instance permissions to assume another role, but no actual permissions by default. I got this idea while setting up security monkey: http://securitymonkey.readthedocs.org/en/latest/quickstart1.html#setup-iam-roles.
#!/bin/bash
#
# Assume the given role, and print out a set of environment variables
# for use with aws cli.
#
# To use:
#
# $ eval $(./iam-assume-role.sh)
#
@dfevre
dfevre / aws_env
Last active March 4, 2019 21:32 — forked from mjul/aws_env
Get environment variables from AWS profile (for use with docker-machine)
# The following is a ~/.zshrc function that exports an aws cli profile from ~/.aws/credentials to environment variables.
aws_env() {
export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id --profile "$1");
export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key --profile "$1");
export AWS_SESSION_TOKEN=$(aws configure get aws_session_token --profile "$1");
export AWS_SECURITY_TOKEN=$(aws configure get aws_security_token --profile "$1");
export AWS_DEFAULT_REGION=$(aws configure get region --profile "$1");
echo "$1 environment variables exported";
}