ictools / env-generator
This package allows you to generate the env files needed in production by retrieving data from AWS Secret Manager
Installs: 1 573
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- aws/aws-sdk-php: ^3
- guzzlehttp/psr7: >=2.4.5
- league/flysystem: ^3.2
- vlucas/phpdotenv: ^5.4
Requires (Dev)
- roave/security-advisories: dev-latest
README
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