0

I would like to be able to define environment variables in AWS ECS task definition like below:

TEST_USER: admin

TEST_PATH: /home/$TEST_USER/workspace

When I echo TEST_PATH:

Actual Value = /home/**$TEST_USER**/workspace

Expected Value = /home/**admin**/workspace

ariabele
  • 355
  • 1
  • 4
  • 9

1 Answers1

0

You can't do that. I don't think Docker in general supports evaluating environment variables like that before exposing them in the container.

If you are using something like CloudFormation or Terraform to create create your Task Definitions, you would use a variable in that tool to store the value, and create the ECS environment variables using that CloudFormatin/Terraform variable.

Otherwise you could edit the entrypoint script of your Docker image to do the following when the container starts up:

export TEST_PATH="/home/$TEST_USER/workspace"
Mark B
  • 183,023
  • 24
  • 297
  • 295