0

enter image description here

I’m new to AWS ECS deployment. This is my first time.

I have updated the .env in my container definition on my AWS account.

But when I run docker exec e718a29eb0e3 env in my container I still seeing the latest value updated.

I even tried

node@db39b382163a:/api$ pm2 restart all

I still not seeing it updated.

Do I need to restart something else ?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
code-8
  • 54,650
  • 106
  • 352
  • 604
  • Is the `.env` a file in the Docker container or are you passing environment variables through the task definition? – Keenan Lawrence Jun 25 '18 at 18:35
  • I am trying to pass the .env via task definition ? Should I create a .env ? Which one is the best practice (create .env on docker container or via the task definition )? – code-8 Jun 25 '18 at 20:07
  • 2
    Via the task definition, otherwise you'll have to rebuild your container each time (even if you layer it right, it's still not the way to go). Are you using Cloudformation or the console to update the task? In either case, after updating the container definitions you still need to create a new revision and then run it to have the env vars updated – Keenan Lawrence Jun 25 '18 at 22:46

1 Answers1

0

The native CodePipeline -> ECS integration will only update the container definitions' image attribute so you cannot use it to manage environment variables. you have a couple of other options:

You can use a Lambda function instead to drive your deployment and do something similar to the above to edit both the image and environment attributes. If you're using CloudFormation to manage your task definition and service, you can use these templates to manage those fields instead of the native integration.

td4u
  • 402
  • 5
  • 17