Class: Role
- Inherits:
-
Object
- Object
- Role
- Defined in:
- lib/aws/sts/role.rb
Instance Attribute Summary collapse
-
#role_arn ⇒ Object
Returns the value of attribute role_arn.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(role_arn, region, profile) ⇒ Role
constructor
A new instance of Role.
- #print_keys ⇒ Object
Constructor Details
#initialize(role_arn, region, profile) ⇒ Role
Returns a new instance of Role.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aws/sts/role.rb', line 11 def initialize(role_arn,region, profile) if self.class.test_role_arn(role_arn) @role_arn = role_arn else raise ArgumentError.new("Role Arn is not valid") end @region = region @profile = profile @client = Aws::STS::Client.new( region: @region, profile: @profile, ) end |
Instance Attribute Details
#role_arn ⇒ Object
Returns the value of attribute role_arn.
9 10 11 |
# File 'lib/aws/sts/role.rb', line 9 def role_arn @role_arn end |
Class Method Details
.blurb ⇒ Object
31 32 33 |
# File 'lib/aws/sts/role.rb', line 31 def self.blurb puts "aws-sts <role>" end |
.test_role_arn(role_arn) ⇒ Object
27 28 29 |
# File 'lib/aws/sts/role.rb', line 27 def self.test_role_arn(role_arn) role_arn =~ /^arn:aws:iam::(\d+):role\/([^\/]+)(\/.+)?$/ end |
Instance Method Details
#print_keys ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/aws/sts/role.rb', line 35 def print_keys credentials = get_keys puts "export AWS_ACCESS_KEY_ID=#{credentials.access_key_id}" puts "export AWS_SECRET_ACCESS_KEY=#{credentials.secret_access_key}" puts "export AWS_SESSION_TOKEN=#{credentials.session_token}" puts "export ASSUMED_ROLE=#{@profile}" puts "# run eval $(ruby Role.rb <profile>)" end |