Class: Clusters::Aws::FetchCredentialsService

Inherits:
Object
  • Object
show all
Defined in:
app/services/clusters/aws/fetch_credentials_service.rb

Constant Summary collapse

MissingRoleError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provision_role, provider: nil) ⇒ FetchCredentialsService

Returns a new instance of FetchCredentialsService.


10
11
12
13
# File 'app/services/clusters/aws/fetch_credentials_service.rb', line 10

def initialize(provision_role, provider: nil)
  @provision_role = provision_role
  @provider = provider
end

Instance Attribute Details

#provision_roleObject (readonly)

Returns the value of attribute provision_role


6
7
8
# File 'app/services/clusters/aws/fetch_credentials_service.rb', line 6

def provision_role
  @provision_role
end

Instance Method Details

#executeObject

Raises:


15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/clusters/aws/fetch_credentials_service.rb', line 15

def execute
  raise MissingRoleError.new('AWS provisioning role not configured') unless provision_role.present?

  ::Aws::AssumeRoleCredentials.new(
    client: client,
    role_arn: provision_role.role_arn,
    role_session_name: session_name,
    external_id: provision_role.role_external_id,
    policy: session_policy
  ).credentials
end