CmdID

CmdID / aws / aws ecs

aws ecs update-task-protection

Updates the protection status of a task. AWS CLI reference

2 examples 4 options Its page in the AWS CLI reference

Opens CmdID with your command. It is read in your browser and sent nowhere.

Examples

from aws-cli, each command read by CmdID

Example 1: To enable task protection for ECS tasks

The following update-task-protection example protects your ECS task from termination during scale-in from Deployments or Service AutoScaling. You can specify custom expiration period for task protection from 1 up to 2,880 minutes (48 hours). If you do not specify expiration period, enabling task protection default time is 2 hours.

aws ecs update-task-protection --cluster ECS-project-update-cluster --tasks c43ed3b1331041f289316f958adb6a24 --protection-enabled --expires-in-minutes 300Identify
--clusterThe short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.
--tasksA list of up to 10 task IDs or full ARN entries.
--protection-enabledSpecify true to mark a task for protection and false to unset protection, making it eligible for termination.
--expires-in-minutesIf you set protectionEnabled to true, you can specify the duration for task protection in minutes.
Its output
{
"protectedTasks": [
    {
        "taskArn": "arn:aws:ecs:us-west-2:123456789012:task/c43ed3b1331041f289316f958adb6a24",
        "protectionEnabled": true,
        "expirationDate": "2024-09-14T19:53:36.687000-05:00"
    }
],
"failures": []
}

Example 2: To disable task protection for ECS tasks

The following update-task-protection example disables the tasks protected from scale in from Deployments or Service AutoScaling.

aws ecs update-task-protection --cluster ECS-project-update-cluster --tasks c43ed3b1331041f289316f958adb6a24 --no-protection-enabledIdentify
--clusterThe short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.
--tasksA list of up to 10 task IDs or full ARN entries.
--no-protection-enabledSpecify true to mark a task for protection and false to unset protection, making it eligible for termination.
Its output
{
    "protectedTasks": [
        {
            "taskArn": "arn:aws:ecs:us-west-2:123456789012:task/c43ed3b1331041f289316f958adb6a24",
            "protectionEnabled": false
        }
    ],
    "failures": []
}

For more formation on task protection, see Protect your Amazon ECS tasks from being terminated by scale-in events in the Amazon ECS Developer Guide.

Options

4 in the AWS CLI reference
--clusterThe short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.
--expires-in-minutesIf you set protectionEnabled to true, you can specify the duration for task protection in minutes.
--protection-enabledSpecify true to mark a task for protection and false to unset protection, making it eligible for termination.
--tasksA list of up to 10 task IDs or full ARN entries.