1

there, I have already an environment variable setup in ECS task definition as shown in the screenshot. And I was supposing that I could simply treat it as an regular env and read it like this in Spring:

@Value("${activeDirectoryPwd}")
private String adPwd;

but somehow the variable adPwd comes back null. Do I have to read it differently?

enter image description here

JackOuttaBox
  • 345
  • 5
  • 12

1 Answers1

2

Environmental variables are environmental variables no matter how they are defined, so there is likely something going on within your containers themselves. Is your Spring application being launched directly in the container or is there another service running it?

As a separate note, you shouldn't pass passwords directly into the task definition like that. Instead you should store it in the Secrets Manager or the Parameter Store and pass the secret through in the task definition. This prevents the secret from being read in the AWS Console.

Robert Hafner
  • 3,364
  • 18
  • 23
  • Thanks for the tip, and we'll move it to secrets eventually, for now just want to figure out how env works here. We are launching Spring directly in a docker container. In this case, is there any specific setup we are missing? or where would you recommend we looking into? – JackOuttaBox Feb 10 '21 at 07:05
  • Are you using a public container I could look at? – Robert Hafner Feb 10 '21 at 16:22
  • It's our company internal one, but, miraculously, it starts working this morning. We use Harness to manage our cicd pipelines and we set the envs there, not sure if this is just a transient error from harness or ECS, will do some investigation. But going back to your answer, an env is just an env, thanks. – JackOuttaBox Feb 10 '21 at 18:53