pflorek / aws-paramstore
This library reads parameters from AWS Parameter Store. It supports a path prefix, an optional shared context and multiple profiles. Returns an multi dimensional array of string|int|float|bool. Integrates directly with zendframework/zend-config-aggregator.
Installs: 8 372
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 1
Open Issues: 1
Requires
- php: >=7.0
- aws/aws-sdk-php: ^3.71
- pflorek/elevator: ^2.0
Requires (Dev)
- phpunit/phpunit: >=5.7 <8.0
Suggests
- zendframework/zend-config-aggregator: Use directly as AWS Parameter Store Config Provider.
README
This library reads parameters from AWS Parameter Store. It supports a path prefix, an optional shared context and multiple profiles. Returns an multi dimensional array of string|int|float|bool. Integrates directly with zendframework/zend-config-aggregator.
Usage
use Aws\Ssm\SsmClient; use PFlorek\AwsParameterStore\ConfigProvider; // Provide bootstrap options $options = [ 'prefix' => '/path/with/prefix', // required 'name' => 'application-name', // required 'profileSeparator' => '_', // default => '_' 'sharedContext' => 'shared-context', // default => '' ]; // Configure AWS Systems Manager Client $client = new SsmClient([ 'version' => 'latest', 'region' => 'eu-central-1', ]); // Or just pass AWS Client options $client = [ 'version' => 'latest', 'region' => 'eu-central-1', ]; // Get provided config with active profiles $environments = ['test']; // Create AWS Parameter Store Config Provider $provider = new ConfigProvider($client, $options, $environments); $config = $provider(); // e.g. returns // //array(1) { // ["service"]=> // array(3) { // ["host"]=> // string(5) "mysql" // ["port"]=> // int(3306) // ["enabled"]=> // bool(true) // } //}
Configuration
Example
Given options:
- prefix := /path/with/prefix
- name := app-name
- profileSeparator := _
- sharedContext = shared
- profiles = ['common', 'test']
Will search for parameters with path beginning with:
- /path/with/prefix/shared
- /path/with/prefix/app-name
- /path/with/prefix/app-name_common
- /path/with/prefix/app-name_test
Installation
Use Composer to install the package:
composer require pflorek/aws-paramstore
Authors
Contribute
Contributions are always welcome!
- Report any bugs or issues on the issue tracker.
- You can download the sources at the package's Git repository.
License
All contents of this package are licensed under the MIT license.