Best way to restart tasks in AWS ECS

I have an AWS ECS cluster, with a service and a task definition. The definition includes two containers whose images are managed in AWS ECR.

I’m already using CircleCI to upload images to that AWS ECR, tagged “latest”.

The task definition uses “latest”. So, if I stop the currently running task, then the service will restart the task with the new image.

Now, I want to stop the current task as part of my CircleCI workflow, basically run these aws commands:

TASK_ID=`aws ecs list-tasks --desired-status "RUNNING" --cluster "streamdelayer-cluster" | grep arn | sed 's/[ "]//g'`
aws ecs stop-task --cluster "streamdelayer-cluster" --task $TASK_ID --reason "Restarting task due to new ECR image deployment"

(keep in mind, the task is in a service, so a new task will be started automatically once I stop the currently running one)

What’s the best way to do this in CircleCI?

UPDATE:
For reference, I thought I’d share what I’m using at the moment. Not sure if it’s the best route or not.

jobs:
  restart_task:
    executor: aws-cli/default
    steps:
      - aws-cli/install
      - run:
          name: Restart task
          command: |
            TASK_ID=`aws ecs list-tasks --desired-status "RUNNING" --cluster "streamdelayer-cluster" | grep arn | sed 's/[ "]//g'`
            AWS_PAGER="" aws ecs stop-task --cluster "streamdelayer-cluster" --task $TASK_ID --reason "Restarting task due to new ECR image deployment"