module HTTPX::Plugins::AwsSdkAuthentication

  1. lib/httpx/plugins/aws_sdk_authentication.rb

This plugin applies AWS Sigv4 to requests, using the AWS SDK credentials and configuration.

It requires the “aws-sdk-core” gem.

Public Class methods

configure(klass)
[show source]
   # File lib/httpx/plugins/aws_sdk_authentication.rb
52 def configure(klass)
53   klass.plugin(:aws_sigv4)
54 end
credentials(profile)
[show source]
   # File lib/httpx/plugins/aws_sdk_authentication.rb
60 def credentials(profile)
61   mock_configuration = Configuration.new(profile)
62   Credentials.new(Aws::CredentialProviderChain.new(mock_configuration).resolve)
63 end
extra_options(options)
[show source]
   # File lib/httpx/plugins/aws_sdk_authentication.rb
56 def extra_options(options)
57   options.merge(max_concurrent_requests: 1)
58 end
load_dependencies(_klass)
[show source]
   # File lib/httpx/plugins/aws_sdk_authentication.rb
48 def load_dependencies(_klass)
49   require "aws-sdk-core"
50 end
region(profile)
[show source]
   # File lib/httpx/plugins/aws_sdk_authentication.rb
65 def region(profile)
66   # https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-core/lib/aws-sdk-core/plugins/regional_endpoint.rb#L62
67   keys = %w[AWS_REGION AMAZON_REGION AWS_DEFAULT_REGION]
68   env_region = ENV.values_at(*keys).compact.first
69   env_region = nil if env_region == ""
70   cfg_region = Aws.shared_config.region(profile: profile)
71   env_region || cfg_region
72 end