Skip to content

ICTools/env-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

This project allows you to generate the env files needed in production by retrieving data from AWS Secret Manager

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages