class Amazonite::Core::Config

Overview

Resolves credentials, region, and endpoint for a Client.

#region resolves from the constructor argument, then AWS_REGION/AWS_DEFAULT_REGION, then the AWS profile's #region.

#access_key_id/#secret_access_key/#session_token resolve together: if both a key and secret are given (via constructor arguments, AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, or a static profile), those are used as-is. Otherwise credentials come from the dynamic provider chain - AssumeRole, SSO cached token, ECS container, then EC2 instance metadata (see the README's "Credentials" section) - and are refreshed automatically as they near expiry.

#dns_timeout/#connect_timeout/#read_timeout/#write_timeout accept either a Number (seconds) or a Time::Span, matching the overloads HTTP::Client itself accepts, and default to nil (the underlying socket library's defaults) when not given.

validate_input controls whether a generated Client calls an operation's input's #validate! before sending the request (default true) - set it to false to skip that check, e.g. to save the extra pass over a large input that's already known-good.

Defined in:

core/config.cr

Constant Summary

Log = ::Log.for(self)

Constructors

Instance Method Summary

Constructor Detail

def self.new(access_key_id : String | Nil = nil, secret_access_key : String | Nil = nil, region : String | Nil = nil, profile : String | Nil = nil, base_url : String | Nil = nil, user_agent : String | Nil = nil, env : Fetcher = EnvFetcher.new, session_token : String | Nil = nil, dns_timeout : Number | Time::Span | Nil = nil, connect_timeout : Number | Time::Span | Nil = nil, read_timeout : Number | Time::Span | Nil = nil, write_timeout : Number | Time::Span | Nil = nil, validate_input : Bool = true) #

[View source]

Instance Method Detail

def access_key_id : String #

[View source]
def aws_profile #

The resolved AWS profile name (constructor profile, then AWS_PROFILE), or nil if none was found.


[View source]
def base_url : String? #

[View source]
def connect_timeout : Time::Span? #

[View source]
def dns_timeout : Time::Span? #

[View source]
def endpoint_url(endpoint_prefix) : String #

The base URL for endpoint_prefix (e.g. "dynamodb") - the constructor's #base_url if given, else the AMAZONITE_<ENDPOINT_PREFIX>_URL environment variable (handy for pointing at a local stack like LocalStack), else https://<endpoint_prefix>.<region>.amazonaws.com.


[View source]
def expiration : Time | Nil #

When the current credentials expire, or nil if they don't (a static access key/secret, or a chain provider that returned none).


[View source]
def read_timeout : Time::Span? #

[View source]
def region : String #

[View source]
def secret_access_key : String #

[View source]
def session_token : String | Nil #

nil unless the current credentials are temporary (from the dynamic provider chain).


[View source]
def user_agent(&) : String #

Yields the User-Agent string to send with a request - the constructor's #user_agent if given, else one built from the amazonite/Crystal/LLVM versions and target architecture (cached after the first call).


[View source]
def validate_input? : Bool #

[View source]
def write_timeout : Time::Span? #

[View source]