Skip to content

Instantly share code, notes, and snippets.

View brandonrich's full-sized avatar

Brandon Rich brandonrich

View GitHub Profile
@brandonrich
brandonrich / user-mfa.sh
Last active April 15, 2016 21:02
If your AWS key pair is restricted by MFA requirements, run this script as shown to contact STS and put temporary credentials into the environment that will last all day. Use these values in your CLI, Boto, or other script.
#!/bin/bash
# Adapted from original by Jaime Preciado-Beas (jpreciad@nd.edu)
# To export env variables to current shell
# run: . user-mfa.sh
# check for user's mfa serial number
: ${AWS_MFA_SERIAL?"Need to set AWS_MFA_SERIAL. Locate at the bottom of your user page under AWS Console -> Identity and Access Management -> Users -> Your netID. Field is labeled 'Multi-Factor Authentication Device'"}
unset AWS_ACCESS_KEY_ID
@brandonrich
brandonrich / gist:67c0ae24b5abfef65134
Created July 5, 2015 02:22
Ruby AWS SDK v2 IAM user MFA example
# shows how to use the Ruby AWS SDK to list EC2 instance IDs
# when your API credentials have been placed under MFA requirements
# Prerequisites:
# you are running on a host that already has the AWS CLI set up with an IAM key pair
# that can describe EC2 instances (OTHERWISE, just pass a
# secret_access_id / secret_access_key pair to the STS client initializer)
# You have installed the Ruby AWS SDK Gem
# http://aws.amazon.com/sdk-for-ruby/
@brandonrich
brandonrich / output
Last active August 29, 2015 14:01
behavior of class <<
a's values:
value of Foo.name: bar
Foo's object ID: 70207511032180
self's object ID: 70207511031980
b's values:
value of Foo.name: bar
Foo's object ID: 70207511032180
self's object ID: 70207511031940