https://github.com/pflorek/php-aws-paramstore
Fetches configuration from AWS Parameter Store
https://github.com/pflorek/php-aws-paramstore
aws config parameter-store php
Last synced: about 1 year ago
JSON representation
Fetches configuration from AWS Parameter Store
- Host: GitHub
- URL: https://github.com/pflorek/php-aws-paramstore
- Owner: pflorek
- License: mit
- Created: 2019-06-26T16:41:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-08T14:15:30.000Z (over 6 years ago)
- Last Synced: 2024-10-19T01:13:18.741Z (over 1 year ago)
- Topics: aws, config, parameter-store, php
- Language: PHP
- Homepage: https://packagist.org/packages/pflorek/aws-paramstore
- Size: 37.1 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP AWS Parameter Store Config Provider
[](https://travis-ci.org/pflorek/php-aws-paramstore)
[](https://coveralls.io/github/pflorek/php-aws-paramstore?branch=master)
[](https://scrutinizer-ci.com/g/pflorek/php-aws-paramstore/?branch=master)
[](https://packagist.org/packages/pflorek/aws-paramstore)
[](https://packagist.org/packages/pflorek/aws-paramstore)
[](https://packagist.org/packages/pflorek/aws-paramstore)
[](https://packagist.org/packages/pflorek/aws-paramstore)
[](https://packagist.org/packages/pflorek/aws-paramstore)
[](https://packagist.org/packages/pflorek/aws-paramstore)
[](https://packagist.org/packages/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.
## Usage
```PHP
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
| parameter | required | default | description |
| :--- | :---: | :---: | :--- |
| prefix | _yes_ | _none_ | The path prefix of the parameters |
| name | _yes_ | _none_ | The application name |
| profileSeparator | _no_ | **'_'** | The separator between application name and profile |
| sharedContext | _no_ | **''** | The shared context for application with parameters under the same path prefix |
## Example
Given options:
- prefix := **/path/with/prefix**
- name := **app-name**
- profileSeparator := **_**
- sharedContext = **shared**
- profiles = **['common', 'test']**
Will search for parameters with path beginning with:
1. /path/with/prefix/shared
1. /path/with/prefix/app-name
1. /path/with/prefix/app-name_common
1. /path/with/prefix/app-name_test
## Installation
Use [Composer] to install the package:
```bash
composer require pflorek/aws-paramstore
```
## Authors
* [Patrick Florek]
## 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].
[Composer]: https://getcomposer.org
[Git repository]: https://github.com/pflorek/php-aws-paramstore
[issue tracker]: https://github.com/pflorek/php-aws-paramstore/issues
[MIT license]: LICENSE
[Patrick Florek]: https://github.com/pflorek