class Role

Attributes

role_arn[RW]

Public Class Methods

blurb() click to toggle source
# File lib/aws/sts/role.rb, line 31
def self.blurb
  puts "aws-sts <role>"
end
new(role_arn,region, profile) click to toggle source
# 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
test_role_arn(role_arn) click to toggle source
# File lib/aws/sts/role.rb, line 27
def self.test_role_arn(role_arn)
  role_arn =~ /^arn:aws:iam::(\d+):role\/([^\/]+)(\/.+)?$/
end

Public Instance Methods

print_keys() click to toggle source

Private Instance Methods

get_keys() click to toggle source
# File lib/aws/sts/role.rb, line 47
def get_keys
  resp = @client.assume_role({
    role_arn: @role_arn,
    role_session_name: @profile,
  })

  resp.credentials
end