Class: IAM::AssumeRoleStatement

Inherits:
Object
  • Object
show all
Defined in:
lib/w-stdlib/aws.rb

Instance Method Summary collapse

Constructor Details

#initialize(s) ⇒ AssumeRoleStatement

Returns a new instance of AssumeRoleStatement.



13
14
15
16
17
# File 'lib/w-stdlib/aws.rb', line 13

def initialize(s)
  @effect = s['Effect']
  @action = s['Action']
  @principal = s['Principal'].map_vals(&:lift_array) # principals can be string or string[]
end

Instance Method Details

#allow?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/w-stdlib/aws.rb', line 19

def allow?
  @effect.downcase == 'allow'
end

#applies_to_principal?(arn) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/w-stdlib/aws.rb', line 31

def applies_to_principal?(arn)
  @principal.fetch('AWS', []).any? { Glob.new(_1).match? arn }
end

#assume_role?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/w-stdlib/aws.rb', line 27

def assume_role?
  @action.include? 'sts:AssumeRole'
end

#deny?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/w-stdlib/aws.rb', line 23

def deny?
  @effect.downcase == 'deny'
end