Unk Nown
Unk Nown

Reputation: 21

Describe max instances for a service in AWS

I do a lot of testing and frequently find out that the AWS ECS prod services are not the same as the test services. Specifically the Auto Scaling Minimum and Maximum tasks are frequently incorrect in test as some well meaning devops decreases them to save money.

I want to use the AWS CLI to grab these details from each (I have read only in both prod and test) and automate the compare prior to the test run.

I have tried both describe-clusters and describe-services but neither seem to give me the maximum tasks. Any ideas on how to proceed?

Upvotes: 2

Views: 245

Answers (1)

Marcin
Marcin

Reputation: 238209

The ECS autoscalling is managed by Application Auto Scaling.

Subsequently, to get MaxCapacity and MinCapacity one has to use application-autoscaling API:

For ECS, the resource-ids parameter is:

The resource type is service and the unique identifier is the cluster name and service name. Example: service/default/sample-webapp

The command's output will contain MaxCapacity and MinCapacity. For example, for ECS:

{
    "ScalableTargets": [
        {
            "ScalableDimension": "ecs:service:DesiredCount",
            "ResourceId": "service/default/web-app",
            "RoleARN": "arn:aws:iam::123456789012:role/ApplicationAutoscalingECSRole",
            "SuspendedState": {
                "DynamicScalingOutSuspended": false,
                "ScheduledScalingSuspended": false,
                "DynamicScalingInSuspended": false
            },
            "CreationTime": 1462558906.199,
            "MinCapacity": 1,
            "ServiceNamespace": "ecs",
            "MaxCapacity": 10
        }
    ]
}

Upvotes: 1

Related Questions