Load values from AWS SSM Parameter store into environment variables for Laravel
composer require sunaoka/aws-ssm-parameters-loader-php
aws ssm put-parameter --name '/path/to/value' --type String --value 'my secret value'
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
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"
// }