sunaoka/laravel-ssm-parameters-loader

Load values from AWS SSM Parameter store into environment variables for Laravel

v1.3.1 2024-08-30 05:00 UTC

This package is auto-updated.

Last update: 2024-10-30 05:32:39 UTC


README

Latest License PHP Laravel Test codecov

Load values from AWS SSM Parameter store into environment variables for Laravel

Installation

composer require sunaoka/laravel-ssm-parameters-loader
php artisan vendor:publish --tag=ssm-parameters-loader-config

Usage

Create a SSM Parameter

aws ssm put-parameter --name '/path/to/value' --type String --value 'my secret value'

Set to .env

MY_PARAMETER=ssm:/path/to/value

Example 1

use Sunaoka\LaravelSsmParametersLoader\ParametersLoader;

echo env('MY_PARAMETER');
// still 'ssm:/path/to/value'

app()->make(ParametersLoader::class)->load();

echo env('MY_PARAMETER');
// my secret value

Example 2

use Sunaoka\LaravelSsmParametersLoader\ParametersLoader;

$result = app()->make(ParametersLoader::class)->getParameters();

var_dump($result);
// array(1) {
//   'MY_PARAMETER' =>
//   string(15) "my secret value"
// }