Skip to content

Instantly share code, notes, and snippets.

@cktricky
Last active May 30, 2017 09:45
Show Gist options
  • Save cktricky/127be4e431563a986f0f to your computer and use it in GitHub Desktop.
Save cktricky/127be4e431563a986f0f to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'aws-sdk'
sts = Aws::STS::Client.new(
region: 'us-east-1',
access_key_id: "<insert access key id>",
secret_access_key: "<secret>"
)
cred = sts.get_session_token({
:serial_number=> "<Insert Serial Number of MFA Devise, ex: arn:aws:iam::1234567890:mfa/someuser@example.com>",
:token_code => "<insert mfa token>",
:duration_seconds=>3600
})
puts "Access Key ID: " + cred.credentials.access_key_id
puts "Secret Access Key: " + cred.credentials.secret_access_key
puts "Session Token: " + cred.credentials.session_token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment