Class: DVLA::Kaping::AWSClient
- Inherits:
-
Object
- Object
- DVLA::Kaping::AWSClient
- Defined in:
- lib/dvla/kaping/aws_client.rb
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize ⇒ AWSClient
constructor
A new instance of AWSClient.
- #select_credentials ⇒ Object
Constructor Details
#initialize ⇒ AWSClient
Returns a new instance of AWSClient.
10 11 12 13 14 15 16 |
# File 'lib/dvla/kaping/aws_client.rb', line 10 def initialize @base_url = Kaping.yaml[:kaping_host] @aws_account_id = Kaping.yaml.dig(:aws, :account_id) @role = Kaping.yaml.dig(:aws, :role) @region = Kaping.yaml.dig(:aws, :region) || 'eu-west-2' Kaping.logger.debug { "AWS Client | base_url: '#{@base_url}'" } end |
Instance Method Details
#connect ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dvla/kaping/aws_client.rb', line 31 def connect credentials = select_credentials signer = Aws::Sigv4::Signer.new(service: 'es', region: @region, credentials_provider: credentials) OpenSearch::Aws::Sigv4Client.new({ host: @base_url, log: false, }, signer) end |
#select_credentials ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dvla/kaping/aws_client.rb', line 18 def select_credentials case Kaping.yaml.dig(:aws, :credential_type) when 'profile' assume_role_profile(@aws_account_id, @role) when 'env' assume_role_env(@aws_account_id, @role) when 'credentials' Aws::CredentialProviderChain.new.resolve else logger.warn { 'Credential type not recognised, please set an option: profile, env or credentials' } end end |