Class: Clusters::Aws::ProvisionService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#providerObject (readonly)

Returns the value of attribute provider


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

def provider
  @provider
end

Instance Method Details

#execute(provider) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/services/clusters/aws/provision_service.rb', line 8

def execute(provider)
  @provider = provider

  configure_provider_credentials
  provision_cluster

  if provider.make_creating
    WaitForClusterCreationWorker.perform_in(
      Clusters::Aws::VerifyProvisionStatusService::INITIAL_INTERVAL,
      provider.cluster_id
    )
  else
    provider.make_errored!("Failed to update provider record; #{provider.errors.full_messages}")
  end
rescue Clusters::Aws::FetchCredentialsService::MissingRoleError
  provider.make_errored!('Amazon role is not configured')
rescue ::Aws::Errors::MissingCredentialsError
  provider.make_errored!('Amazon credentials are not configured')
rescue ::Aws::STS::Errors::ServiceError => e
  provider.make_errored!("Amazon authentication failed; #{e.message}")
rescue ::Aws::CloudFormation::Errors::ServiceError => e
  provider.make_errored!("Amazon CloudFormation request failed; #{e.message}")
end