Bootstrap FreeKB - Amazon Web Services (AWS) Elastic Container Service (ECS) - List Task Definitions using the AWS CLI
Amazon Web Services (AWS) Elastic Container Service (ECS) - List Task Definitions using the AWS CLI


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

A Task Definition is kind of like a Dockerfile or a Kubernetes deployment YAML file, in that it contains keys and values that are used to define how something should be, such as the settings for a container, such as:

  • which Docker image to use
  • which ports to expose
  • how much CPU and memory to reserve
  • how to collect logs
  • environment variables

A Task Definition can be used to create one or more Tasks or one or more Services.

  • Task is created when you run a Task directly, which launches container(s) (defined in the task definition) until they are stopped or exit on their own, at which point they are not replaced automatically. Running Tasks directly is ideal for short-running jobs, perhaps as an example of things that were accomplished via CRON

  • Service is used to guarantee that you always have some number of Tasks running at all times. If a Task's container exits due to an error, or the underlying EC2 instance fails and is replaced, the ECS Service will replace the failed Task. This is why we create Clusters so that the Service has plenty of resources in terms of CPU, Memory and Network ports to use. To us it doesn't really matter which instance Tasks run on so long as they run. A Service configuration references a Task definition. A Service is responsible for creating Tasks.

 

The aws ecs list-task-definitions command can be used to list the ECS Task Definitions that have been created. Something like this should be returned.

~]$ aws ecs list-task-definitions
{
    "taskDefinitionArns": [
        "arn:aws:ecs:us-east-1:123456789012:task-definition/my-task-definition:1",
        "arn:aws:ecs:us-east-1:123456789012:task-definition/my-task-definition:2"
    ]
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 4fdb69 in the box below so that we can be sure you are a human.