Module: MovableInk::AWS::IAM

Included in:
MovableInk::AWS
Defined in:
lib/movable_ink/aws/iam.rb

Instance Method Summary collapse

Instance Method Details

#is_arn_iam_assumed_role?(arn, rolename = nil, exact_match = true) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/movable_ink/aws/iam.rb', line 16

def is_arn_iam_assumed_role?(arn, rolename = nil, exact_match = true)
  # arn:aws:sts::account:assumed-role/role-name/role-session-name
  role_name_session_delimiter = (exact_match) ? '/' : ''
  !arn.match(/arn:aws:sts::\d+:assumed\-role\/#{(rolename) ? rolename + role_name_session_delimiter : ''}/).nil?
end

#is_arn_iam_role?(arn, rolename = nil) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/movable_ink/aws/iam.rb', line 11

def is_arn_iam_role?(arn, rolename = nil)
  # arn:aws:iam::account:role/role-name-with-path
  !arn.match(/arn:aws:iam::\d+:role\/#{(rolename) ? rolename + '$' : ''}/).nil?
end

#is_arn_iam_user?(arn, username = nil) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/movable_ink/aws/iam.rb', line 6

def is_arn_iam_user?(arn, username = nil)
  # arn:aws:iam::account:user/user-name-with-path
  !arn.match(/arn:aws:iam::\d+:user\/#{(username) ? username + '$' : ''}/).nil?
end