Created
January 23, 2017 22:02
-
-
Save jhmartin/c669c902c59d2dc33741d42b4e20fbf7 to your computer and use it in GitHub Desktop.
How to use cross-account roles in AWS RUby SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
role_credentials = Aws::AssumeRoleCredentials.new( | |
client: Aws::STS::Client.new(), | |
role_arn: "arn:aws:iam::123:role/cross-account-role", | |
role_session_name: ENV['USER'], | |
serial_number: "arn:aws:iam::123:mfa/usernamehere", | |
token_code: ARGV[0] | |
) | |
cw = Aws::CloudWatch::Client.new( | |
credentials: role_credentials | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment