Class: Role

Inherits:
Object
  • Object
show all
Defined in:
lib/credsummoner/role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, arn:, principal_arn:) ⇒ Role

Returns a new instance of Role.



6
7
8
9
10
# File 'lib/credsummoner/role.rb', line 6

def initialize(name:, arn:, principal_arn:)
  @name = name
  @arn = arn
  @principal_arn = principal_arn
end

Instance Attribute Details

#arnObject (readonly)

Returns the value of attribute arn.



4
5
6
# File 'lib/credsummoner/role.rb', line 4

def arn
  @arn
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/credsummoner/role.rb', line 4

def name
  @name
end

#principal_arnObject (readonly)

Returns the value of attribute principal_arn.



4
5
6
# File 'lib/credsummoner/role.rb', line 4

def principal_arn
  @principal_arn
end

Instance Method Details

#assume(saml, duration, region) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/credsummoner/role.rb', line 12

def assume(saml, duration, region)
  sts = Aws::STS::Client.new(region: region)
  sts.assume_role_with_saml(
    principal_arn: principal_arn,
    role_arn: arn,
    saml_assertion: saml.response,
    duration_seconds: duration
  ).credentials
end

#to_sObject



22
23
24
# File 'lib/credsummoner/role.rb', line 22

def to_s
  name
end