Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up secrets in ECS task definition for container environment variable?

Tags:

amazon-ecs

I try to set up AWS ECS task definition of my docker frontend container to an AWS backend url.

In my .env.production:

REACT_APP_HOST=secrets.BACKEND_URL

how should I modify my secrets format or syntax, so that in my ECS task definition when I set container environment variable can be correctly used? key: BACKEND_URL value:xxxxx

Thanks

like image 856
lllllll Avatar asked Dec 08 '25 17:12

lllllll


1 Answers

You need to use Secrets block in ECS task definition, then during run time, ECS will retrieve the secret value and inject as env variable into container.

Some docs if you use with CF, CLI or TF are similar as well

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-taskdefinition.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-secret.html

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data-secrets.html

like image 134
sayboras Avatar answered Dec 11 '25 22:12

sayboras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!