A bit of background, a while back created a cfm template which allows us to deploy a new stack of our app on aws, which has a redis, db,2 security groups,cluster, target grous, ,alb, iam role, inline policies, couple of services, each service has service discovery entry, etc and more importantly right now it creates multiple parameter stores which are named "${cluster}/${env}/${nameOfTheParam}"
All of the parameters are env variables which are inputted when a new stack is being created.
Right now our env have grown to the point of having them over a few dozen, a bit overdue but im looking into simplifying the process.
What i ultimately want to achieve is instead of adding each env variable one by one as a param into an input field at the cloudformation interface, to simple copy and paste them in a bulk (in a sense copy the content from the .env file) into a single input field as a cfm parameter.
What would be my option to achieve it?
2
Answers
Apparently my current use use is considered an IoC anti-pattern, the reason being
.env
is the standard way to populate external configuration to your software.I do agree on that. We always look for that for any framework ( docker-compose, create-react-app, terraform vars, … etc)
Unfortunately, not all frameworks/platforms supports that .i.e. AWS Cloudfromation templates.
However, it’s never too late, you could always populate
.env
by a single command:If you want to make it consistent everywhere, you could restrict your team to always use
Makefile
to build/run . In your case. it’s interpolation template then create/update stack from it (or run it).If you will go with
Makefile
, then your makefile should start by:Another point, if you want only to deal with the
.env
file locally (in your terminal) and let’s say you are using OH-my-ZSH, then you could load the .env plugin of Oh-My-ZSH: