Class ConfigurationProvider
- Aws\AbstractConfigurationProvider
-
Aws\Sts\RegionalEndpoints\ConfigurationProvider implements Aws\ConfigurationProviderInterface
- Namespace: Aws\Sts\RegionalEndpoints
- Located at Sts/RegionalEndpoints/ConfigurationProvider.php
A configuration provider is a function that returns a promise that is
fulfilled with a Aws\Sts\RegionalEndpoints\ConfigurationInterface
or rejected with an Aws\Sts\RegionalEndpoints\Exception\ConfigurationException
.
use Aws\Sts\RegionalEndpoints\ConfigurationProvider; $provider = ConfigurationProvider::defaultProvider(); // Returns a ConfigurationInterface or throws. $config = $provider()->wait();
Configuration providers can be composed to create configuration using conditional logic that can create different configurations in different environments. You can compose multiple providers into a single provider using \Aws\Sts\RegionalEndpoints\ConfigurationProvider::chain. This function accepts providers as variadic arguments and returns a new function that will invoke each provider until a successful configuration is returned.
// First try an INI file at this location. $a = ConfigurationProvider::ini(null, '/path/to/file.ini'); // Then try an INI file at this location. $b = ConfigurationProvider::ini(null, '/path/to/other-file.ini'); // Then try loading from environment variables. $c = ConfigurationProvider::env(); // Combine the three providers together. $composed = ConfigurationProvider::chain($a, $b, $c); // Returns a promise that is fulfilled with a configuration or throws. $promise = $composed(); // Wait on the configuration to resolve. $config = $promise->wait();
Methods Summary
-
static
defaultProvider ( array $config = [] )
Create a default config provider that first checks for environment variables, then checks for a specified profile in the environment-defined config file location (env variable is 'AWS_CONFIG_FILE', file location defaults to ~/.aws/config), then checks for the "default" profile in the environment-defined config file location, and failing those uses a default fallback set of configuration options.
-
static
env ( )
Provider that creates config from environment variables.
-
static
fallback ( )
Fallback config options when other sources are not set.
-
static
ini ( string|null $profile = null, string|null $filename = null )
Config provider that creates config using a config file whose location is specified by an environment variable 'AWS_CONFIG_FILE', defaulting to ~/.aws/config if not specified
-
static
unwrap ( mixed $config )
Unwraps a configuration object in whatever valid form it is in, always returning a ConfigurationInterface object.
Methods inherited from Aws\AbstractConfigurationProvider
Methods Details
static callable defaultProvider ( array $config = [] )
Create a default config provider that first checks for environment variables, then checks for a specified profile in the environment-defined config file location (env variable is 'AWS_CONFIG_FILE', file location defaults to ~/.aws/config), then checks for the "default" profile in the environment-defined config file location, and failing those uses a default fallback set of configuration options.
This provider is automatically wrapped in a memoize function that caches previously provided config options.
Parameters
array | $config = [] |
Returns
callable |
Implementation of
static callable env ( )
Provider that creates config from environment variables.
Returns
callable |
static callable fallback ( )
Fallback config options when other sources are not set.
Returns
callable |
static callable ini ( string|null $profile = null, string|null $filename = null )
Config provider that creates config using a config file whose location is specified by an environment variable 'AWS_CONFIG_FILE', defaulting to ~/.aws/config if not specified
Parameters
string|null | $profile = null | Profile to use. If not specified will use the "default" profile. |
string|null | $filename = null | If provided, uses a custom filename rather than looking in the default directory. |
Returns
callable |
static
Aws\Sts\RegionalEndpoints\ConfigurationInterface
unwrap (
mixed
$config
)
Unwraps a configuration object in whatever valid form it is in, always returning a ConfigurationInterface object.
Parameters
mixed | $config |
Returns
Aws\Sts\RegionalEndpoints\ConfigurationInterface |
Exceptions
InvalidArgumentException |
Constants summary
string |
DEFAULT_ENDPOINTS_TYPE
|
#
'legacy'
|
string |
ENV_ENDPOINTS_TYPE
|
#
'AWS_STS_REGIONAL_ENDPOINTS'
|
string |
INI_ENDPOINTS_TYPE
|
#
'sts_regional_endpoints'
|