View Source aws_credentials_provider behaviour (aws_credentials v0.3.2)
This is the behaviour definition for a credential provider module and it iterates over a list of providers. You may set the credential_providers` Erlang environment variable if you want to restrict checking only a certain subset of the default list or if you want to use your own custom providers. Default order of checking for credentials is: <ol> <li>Erlang application environment</li> <li>OS environment</li> <li>Credentials from AWS file</li> <li>ECS Task credentials</li> <li>EC2 credentials</li> </ol> Providers are expected to implement a function called `fetch/1
which takes as its argument a proplist of options which may influence the operation of the provider. The fetch/1 function should return either {ok, Credentials, Expiration}
or {error, Reason}
.
If a provider returns {ok, ...} then evaluation stops at that provider. If it returns {error, ...} then the next provider is executed in order until either a set of credentials are returned or the tuple {error, no_credentials}
is returned.
Summary
Types
-type expiration() :: binary() | pos_integer() | infinity.
-type provider() :: aws_credentials_env | aws_credentials_file | aws_credentials_ecs | aws_credentials_ec2 | module().
Callbacks
-callback fetch(options()) -> {ok, aws_credentials:credentials(), expiration()} | {error, any()}.
Functions
-spec fetch() -> {ok, aws_credentials:credentials(), expiration()} | {error, no_credentials} | {error, error_log()}.
-spec fetch(options()) -> {ok, aws_credentials:credentials(), expiration()} | {error, no_credentials} | {error, error_log()}.