title: How to access ecs task definition environment variables in nodejs?
body: <p>I am trying to access the environment variables set in a task definition, inside my nodejs app, with process.env.</p>
  
  <p>I use a Dockerfile to create an image of the project, upload it to ECR, then use this image in the task definition. </p>
  
  <p>I set enviroment variables for the nodejs app, inside the Dockerfile, like this:</p>
  
  <pre><code># Dockerfile
  ...
  RUN ROOT_DIR='/'
  RUN PUBLIC_DIR='/public'
  ...
  </code></pre>
  
  <p>I have this task definition:</p>
  
  <pre><code># task_definition.json
  ...
  "environment" : [
      { "name" : "KeyOne", "value" : "KeyOneValue" },
      { "name" : "KeyTwo", "value" : "KeyTwoValue" }
  ]
  ...
  </code></pre>
  
  <p>I am not able to access <code>process.env.KeyOne</code> / <code>process.env.KeyTwo</code> (they are <code>undefined</code>)</p>
  
  <p>I would like to be able to set those environment variables from the task definition and then reference them inside nodejs app with <code>process.env</code> instead of setting them inside the Dockerfile.</p>