Class: LittleGhost::Providers::Bedrock::CredentialResolver
- Inherits:
-
Object
- Object
- LittleGhost::Providers::Bedrock::CredentialResolver
- Defined in:
- lib/little_ghost/providers/bedrock/credential_resolver.rb
Overview
Resolves common AWS credentials without depending on an AWS SDK.
Instance Method Summary collapse
-
#call ⇒ Object
Returns the first complete credential set from the environment, shared credentials, container metadata, or IMDSv2.
-
#initialize(environment: ENV, profile: nil, credentials_file: nil) ⇒ CredentialResolver
constructor
Uses
environmentand the selected shared-credentialsprofile. -
#region ⇒ Object
Returns the configured AWS region, when one can be resolved.
Constructor Details
#initialize(environment: ENV, profile: nil, credentials_file: nil) ⇒ CredentialResolver
Uses environment and the selected shared-credentials profile.
22 23 24 25 26 |
# File 'lib/little_ghost/providers/bedrock/credential_resolver.rb', line 22 def initialize(environment: ENV, profile: nil, credentials_file: nil) @environment = environment @profile = profile || environment["AWS_PROFILE"] || "default" @credentials_file = credentials_file || environment["AWS_SHARED_CREDENTIALS_FILE"] || File.("~/.aws/credentials") end |
Instance Method Details
#call ⇒ Object
Returns the first complete credential set from the environment, shared credentials, container metadata, or IMDSv2.
30 31 32 33 |
# File 'lib/little_ghost/providers/bedrock/credential_resolver.rb', line 30 def call from_environment || from_profile || from_container || || raise(CredentialError, "No AWS credentials were found in the environment, selected shared profile, container credentials, or IMDSv2") end |
#region ⇒ Object
Returns the configured AWS region, when one can be resolved.
36 37 38 |
# File 'lib/little_ghost/providers/bedrock/credential_resolver.rb', line 36 def region @environment["AWS_REGION"] || @environment["AWS_DEFAULT_REGION"] || profile_values(config_file)["region"] end |