Class: IAM::AssumeRoleStatement
- Inherits:
-
Object
- Object
- IAM::AssumeRoleStatement
- Defined in:
- lib/w-stdlib/aws.rb
Instance Method Summary collapse
- #allow? ⇒ Boolean
- #applies_to_principal?(arn) ⇒ Boolean
- #assume_role? ⇒ Boolean
- #deny? ⇒ Boolean
-
#initialize(s) ⇒ AssumeRoleStatement
constructor
A new instance of AssumeRoleStatement.
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
19 20 21 |
# File 'lib/w-stdlib/aws.rb', line 19 def allow? @effect.downcase == 'allow' end |
#applies_to_principal?(arn) ⇒ 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
27 28 29 |
# File 'lib/w-stdlib/aws.rb', line 27 def assume_role? @action.include? 'sts:AssumeRole' end |
#deny? ⇒ Boolean
23 24 25 |
# File 'lib/w-stdlib/aws.rb', line 23 def deny? @effect.downcase == 'deny' end |