omenejoseph/dynamic-env

A package to dynamically generate .env values from secret services like AWS secrets

1.0.0 2022-07-31 09:42 UTC

This package is auto-updated.

Last update: 2024-04-30 00:32:50 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

So imagine you are onboarding a new member of your team and you need to send them all the variables they need to be up and running in your laravel application or you add a new variable to your .env file and you want all your engineers to be able to have that new variable and its actual value you cannot push to git in .env example, this package utilises AWS secrets to help solve this problem. With as little as one command you can sync your current .env file to AWS secrets manager and ask your team to re populate their .env file with all the new variables added. Another advantage of this package is that you are able to specify which environment you want to sync to and populate from, thus properly seperating your environments making them clean and tidy.

Installation

You can install the package via composer:

composer require omenejoseph/dynamic-env

Dont forget to publish the application config and prefill with the appopriate credentials

return [
    /* Secret manager */
    'secret_manager' => 'aws',

    /* AWS credentials */
    'aws_key' => env('AWS_ACCESS_KEY_ID'),
    'aws_secret' => env('AWS_SECRET_ACCESS_KEY'),
    'aws_secret_region' => env('AWS_SECRET_REGION'),

    /* Environments that you would be saving the envs to */
    'environments' => [
        'local',
        'qa',
        'production'
    ],

    /* suffix appended to .env when generating the new file eg. .env.sync */
    'env-suffix' => 'sync',
];

Usage

php artisan sync:env

This command asks for the environment you want to sync to and populates AWS secret with the variables in your current .env file

php artisan populate:env

This command asks for the environment you want to populate from and replaces your current .env file with the env variables for that environment on AWS secrets.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email runoomene01@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.