Is it possible to detect Fargate without trying the metadata API

Viewed 1314

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

1 Answers

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

Related