I have a multicontainer docker environment running on AWS Elastic Beanstalk (ECS under the hood). Each instance in the cluster is running all of the containers (proxy, auth, api, client, notifications). I am using Codepipeline and Codebuild as a CICD linked to Github push to master branch.
The flow to build the prod environment for any one of the services currently looks like:
PR into master -> push to Github -> triggers Codepipeline -> triggers Codebuild (here I build, tag, and push a docker image created from a Dockerfile in the source code to Elastic Container Registrary [ECR]).
Once the image is pushed to ECR I can update the Elastic Beanstalk environment to start using the new image for that service.
I do not understand how I can get environment variables into each of the services. I have used the environment section of elastic beanstalk before but how can this work when I have a multicontainer environment? For instance one service might have DB_CONNECTION_STRING=foo
and another might have DB_CONNECTION_STRING=bar
. So using the centralised environment properties section of elastic beanstalk will not work.
I also can't push the env file to source code as it contains passwords/secrets so I cannot add it as part of the build phase. Unless I can add all of the environment variables in Codepipeline? Or should I use a Secrets manager?
What is the best practices on this?
Also important to note that the build phase is the same for all of the services.
Thanks