Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 1.72 KB

README.md

File metadata and controls

64 lines (46 loc) · 1.72 KB

Env Generator

The architecture imagined to use this component is a monorepo deployed on an AWS EC2 instance.

This tool allows you to download environment variables from AWS Secrets Manager and add them to your environment files. It is useful if you have several components.

monorepo
├── api                 # An api component
│   ├── env             # If ENV_GENERATOR_SPECIFIC_PATH=env
│   │   └── prod.env    # env-generator will generate this file
│   └── ...             
├── redis               
│   ├── env             # If ENV_GENERATOR_SPECIFIC_PATH=env  
│   │   └── prod.env    # env-generator will generate this file
│   └── ... 
├── ... 
└── .env                # Specify here the environment variables for env-generator

Install

1. Create a secret

  • Create a secret in AWS Secrets Manager :
  • You can have several keys/values in a secret
  • Secret name: 'projectName/env/component/secretName'* ⚠

(*) E.g.: mysite/prod/api/top_secret

2. Create .env

Add this to the root of your project

ENV_GENERATOR_PROJECT_NAME=
ENV_GENERATOR_APP_ENV=
ENV_GENERATOR_AWS_USER_KEY=
ENV_GENERATOR_AWS_USER_SECRET=
ENV_GENERATOR_AWS_REGION=


### Optional ###
# This variable allows you to define a specific path for your .env files
ENV_GENERATOR_SPECIFIC_PATH=

3. Run

Run this in the root of your project:

With Docker

docker run --env-file .env -v ${PWD}:/app davidgodefroid/env-generator:v1

Or with php script

composer require ictools/env-generator  
php vendor/ictools/env-generator/src/generate.php