5

Is there a possibility for an application that is launched as Fargate task to determine if it runs inside Amazon ECS without trying the task metadata endpoint?

It would be great if there are environment variables or files that can be read.

I also asked this question in the AWS forum: https://forums.aws.amazon.com/thread.jspa?threadID=296444

Christian Ammer
  • 7,464
  • 6
  • 51
  • 108

1 Answers1

9

Is there a possibility for an application that is launched as Fargate task to determine if it runs inside Amazon ECS without trying the task metadata endpoint?

The env variable AWS_EXECUTION_ENV will return the ECS launch type.

The values of this environment variable are

  • AWS_ECS_EC2 for ECS
  • AWS_ECS_FARGATE for Fargate

i.e. AWS_EXECUTION_ENV=AWS_ECS_FARGATE

SomeGuyOnAComputer
  • 5,414
  • 6
  • 40
  • 72
bluescores
  • 4,437
  • 1
  • 20
  • 34
  • Great, I can see this environment variable now with platform version 1.3.0. I'm pretty sure it wasn't there in version 1.1.0. Do you know if this variable is also documented, I couldn't find one? – Christian Ammer Jan 23 '19 at 07:54
  • I think that's exactly right, I think it's a recent addition. We implemented something like this that used the metadata service less than a year ago; if this variable were available we would just use it. It wasn't there at the time. I looked for documentation as well and could find none. – bluescores Jan 23 '19 at 13:50