Search code examples
amazon-web-servicesamazon-ecs

ECS service aws-cli vs. dashboard


Currently experiencing a weird behaviour of AWS ECS tool.

I find 2 different behaviours when using the aws-cli and the web dashboard.

The context is that I have an ECS cluster set up, I am writting a script that automates my deployment by (among other steps) creating or updating an ECS service.

Part of my script uses the command aws ecs describe-services And it is here that I find different information than the dashboard (on the page of my cluster).

Indeed, when the service is created and ACTIVE if I run :

aws ecs describe-services --services my_service --cluster my_cluster

The service will show up as an output with all the informations that I need to parse. It will show up as well on the web dashboard as ACTIVE.

The problem is when I delete the service from the dashboard. As expected, it is deleted from the list and I can eventually recreate one from the dashboard with the same name.

But if when the service is deleted, I re-run the command above, the output will show the service as INACTIVE and all the infos about the previously deleted service will still appear.

If the service is deleted, shouldn't the command return the service as MISSING :

{
    "services": [],
    "failures": [
        {
            "reason": "MISSING",
            "arn": "arn:aws:ecs:<my_regions>:<my_id>:service/my_service"
        }
    ]
}

Because this complicates the parsing in my script, and even if I can find a workaround (maybe trying to create the service even if INACTIVE rather than not existing), it is kind of weird that even deleted, the service is still here, somewhere, clutering my stack.

Edit : I am using the latest versio of the aws-cli


Solution

  • This is the default behavior provided by aws. Please check below documentation:

    When you delete a service, if there are still running tasks that require cleanup, the service status moves from ACTIVE to DRAINING , and the service is no longer visible in the console or in ListServices API operations. After the tasks have stopped, then the service status moves from DRAINING to INACTIVE . Services in the DRAINING or INACTIVE status can still be viewed with DescribeServices API operations. However, in the future, INACTIVE services may be cleaned up and purged from Amazon ECS record keeping, and DescribeServices API operations on those services return a ServiceNotFoundException error.

    delete-service