Reputation: 469
I have AWS container running in ECS. Is there a way we can get the host Task or TaskDefinition info from container code? My container is dotnet core API. So, I am looking for a way to read the hosted/parent task/taskdefinition from my dotnet C# code.
Thank you.
Upvotes: 0
Views: 229
Reputation: 2988
Using the AWS CLI together with the ECS CLI (make sure you have both installed). You can list all tasks for your cluster like this:
aws ecs list-tasks --cluster your-cluster-name
It will return something like this:
{
"taskArns": [
"arn:aws:ecs:us-east-1:5xxx:task/1133xxxxxxc"
]
}
Then you can use the returned ARN to describe multiple tasks like this:
aws ecs describe-tasks --tasks arn:aws:ecs:us-east-1:5xxx:task/1133xxxxxxc --cluster your-cluster-name
Upvotes: 1