Class: AwsMfaSecure::Exports
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Exports
constructor
A new instance of Exports.
- #run ⇒ Object
- #script ⇒ Object
Methods inherited from Base
#aws_cli_installed?, #aws_cli_setup?, #aws_config, #aws_mfa_env_set?, #aws_profile, #credentials, #fetch_creds?, #get_session_token, #good_session_creds?, #iam_mfa?, #mfa_prompt, #mfa_serial, #save_creds, #session_creds_path, #shell_get_session_token, #sts
Constructor Details
#initialize(options = {}) ⇒ Exports
Returns a new instance of Exports.
3 4 5 6 |
# File 'lib/aws_mfa_secure/exports.rb', line 3 def initialize(={}) @options = @aws_profile = aws_profile end |
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/aws_mfa_secure/exports.rb', line 8 def run unless iam_mfa? $stderr.puts "WARN: mfa_serial is not configured for this AWS_PROFILE=#{@aws_profile}" return end if fetch_creds? resp = get_session_token save_creds(resp.credentials.to_h) end puts script end |
#script ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/aws_mfa_secure/exports.rb', line 22 def script <<~EOL export AWS_ACCESS_KEY_ID=#{credentials["access_key_id"]} export AWS_SECRET_ACCESS_KEY=#{credentials["secret_access_key"]} export AWS_SESSION_TOKEN=#{credentials["session_token"]} EOL end |