Class: LambdaWhenever::IamRole

Inherits:
Object
  • Object
show all
Defined in:
lib/lambda_whenever/iam_role.rb

Overview

The IamRole class is responsible for interacting with AWS IAM roles.

Instance Method Summary collapse

Constructor Details

#initialize(option) ⇒ IamRole

Returns a new instance of IamRole.



6
7
8
9
10
11
# File 'lib/lambda_whenever/iam_role.rb', line 6

def initialize(option)
  client = option.iam_client
  @resource = Aws::IAM::Resource.new(client: client)
  @role_name = option.iam_role
  @role = resource.role(@role_name)
end

Instance Method Details

#arnObject



13
14
15
# File 'lib/lambda_whenever/iam_role.rb', line 13

def arn
  role&.arn
end

#exists?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/lambda_whenever/iam_role.rb', line 17

def exists?
  !!arn
rescue Aws::IAM::Errors::NoSuchEntity
  false
end