Skip to content

Instantly share code, notes, and snippets.

@rodolfobandeira
Forked from cktricky/aws_sts_ruby.rb
Created October 4, 2016 20:11
Show Gist options
  • Save rodolfobandeira/95a4900d3c022c33fccf36b518aa12bd to your computer and use it in GitHub Desktop.
Save rodolfobandeira/95a4900d3c022c33fccf36b518aa12bd 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/[email protected]>",
: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