sunaoka / aws-ssm-parameters-loader-php
Load values from AWS SSM Parameter store into environment variables
v1.0.1
2024-08-30 04:51 UTC
Requires
- php: ^8.0
- aws/aws-sdk-php: ^3.20.1
Requires (Dev)
- phpstan/phpstan: ^1.12.0
- phpunit/phpunit: ^9.6 || ^10.5 || ^11.2
This package is auto-updated.
Last update: 2024-08-30 04:51:27 UTC
README
Load values from AWS SSM Parameter store into environment variables for Laravel
Installation
composer require sunaoka/aws-ssm-parameters-loader-php
Usage
Create a SSM Parameter
aws ssm put-parameter --name '/path/to/value' --type String --value 'my secret value'
Example 1
use Aws\Ssm\SsmClient; use Sunaoka\SsmParametersLoader\ParametersLoader; putenv('MY_PARAMETER=ssm:/path/to/value') $client = new SsmClient([ // arguments ]); $loader = new ParametersLoader($client, 'ssm:'); $loader->load(); echo env('MY_PARAMETER'); // my secret value
Example 2
use Aws\Ssm\SsmClient; use Sunaoka\SsmParametersLoader\ParametersLoader; putenv('MY_PARAMETER=ssm:/path/to/value') $client = new SsmClient([ // arguments ]); $loader = new ParametersLoader($client, 'ssm:'); $result = $loader->getParameters(); var_dump($result); // array(1) { // 'MY_PARAMETER' => // string(15) "my secret value" // }