Task metadata available for Amazon ECS tasks on EC2
The Amazon ECS container agent provides a method to retrieve various task metadata and
Docker stats
-
Task metadata endpoint version 4 – Provides a variety of metadata and Docker stats to containers. Can also provide network rate data. Available for Amazon ECS tasks launched on Amazon EC2 Linux instances running at least version
1.39.0
of the Amazon ECS container agent. For Amazon EC2 Windows instances that useawsvpc
network mode, the Amazon ECS container agent must be at least version1.54.0
. For more information, see Amazon ECS task metadata endpoint version 4. -
Task metadata endpoint version 3 – Provides a variety of metadata and Docker stats to containers. Available for Amazon ECS tasks launched on Amazon EC2 Linux instances running at least version
1.21.0
of the Amazon ECS container agent. For Amazon EC2 Windows instances that useawsvpc
network mode, the Amazon ECS container agent must be at least version1.54.0
. For more information, see Amazon ECS task metadata endpoint version 3. -
Task metadata endpoint version 2 – Available for Amazon ECS tasks launched on Amazon EC2 Linux instances running at least version
1.17.0
of the Amazon ECS container agent. For Amazon EC2 Windows instances that useawsvpc
network mode, the Amazon ECS container agent must be at least version1.54.0
. For more information, see Amazon ECS task metadata endpoint version 2.
If your Amazon ECS task is hosted on Amazon EC2, you can also access task host metadata using the Instance Metadata Service (IMDS) endpoint. The following command, when run from within the instance hosting the task, lists the ID of the host instance.
curl http://169.254.169.254/latest/meta-data/
instance-id
If your Amazon ECS task is hosted on Amazon EC2 and in an IPv6-only configuration, you can access task host metadata using the IPv6 IMDS endpoint. The following command, when run from within the instance hosting the task, lists the ID of the host instance over IPv6.
curl http://[fd00:ec2::254]/latest/meta-data/
instance-id
To access the IPv6 IMDS endpoint, enable the IPv6 IMDS endpoint on your container
instance and also configure the metadata service endpoint mode using the IMDS credential
provider for your chosen SDK to IPv6
. For more information about enabling
the IPv6 IMDS endpoint for your container instance, see Configure
the Instance Metadata Service options in
Amazon EC2 User Guide. For more information about IMDS credential
provider for SDKs, see IMDS credential
provider in the AWS SDKs and Tools Reference
Guide.
Note
The IPv6 IMDS endpoint is not accessible when the awsvpcTrunking
account setting is enabled. To access container instance IAM role credentials when
awsvpcTrunking
is enabled, you can use a task IAM role instead. For more
information about task IAM roles, see Amazon ECS task IAM role.
The information you can obtain from the endpoint is divided into categories such as
. For more information about
the different categories of host instance metadata you can obtain using the endpoint,
see Instance metadata categories .instance-id