Class: Awful::Sts
Instance Method Summary collapse
Methods inherited from Cli
Constructor Details
This class inherits a constructor from Awful::Cli
Instance Method Details
#assume_role(arn, name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/awful/sts.rb', line 19 def assume_role(arn, name) opts = only_keys_matching(symbolize_keys(), %i[duration_seconds policy]) params = { role_arn: arn, role_session_name: name }.merge(opts) sts.assume_role(params).output do |session| if [:env] puts %i[access_key_id secret_access_key session_token].map { |var| "export AWS_#{var.upcase}=#{session.credentials.send(var)}" } else puts YAML.dump(stringify_keys(session.to_hash)) end end end |