GetTaskProtection
Retrieves the protection status of tasks in an Amazon ECS service.
Request Syntax
{
"cluster": "string
",
"tasks": [ "string
" ]
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
Response Syntax
{
"failures": [
{
"arn": "string",
"detail": "string",
"reason": "string"
}
],
"protectedTasks": [
{
"expirationDate": number,
"protectionEnabled": boolean,
"taskArn": "string"
}
]
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- failures
-
Any failures associated with the call.
Type: Array of Failure objects
- protectedTasks
-
A list of tasks with the following information.
-
taskArn
: The task ARN. -
protectionEnabled
: The protection status of the task. If scale-in protection is turned on for a task, the value istrue
. Otherwise, it isfalse
. -
expirationDate
: The epoch time when protection for the task will expire.
Type: Array of ProtectedTask objects
-
Errors
For information about the errors that are common to all actions, see Common Errors.
- AccessDeniedException
-
You don't have authorization to perform the requested action.
HTTP Status Code: 400
- ClientException
-
These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.
The following list includes additional causes for the error:
-
The
RunTask
could not be processed because you use managed scaling and there is a capacity error because the quota of tasks in thePROVISIONING
per cluster has been reached. For information about the service quotas, see Amazon ECS service quotas.
HTTP Status Code: 400
-
- ClusterNotFoundException
-
The specified cluster wasn't found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region specific.
HTTP Status Code: 400
- InvalidParameterException
-
The specified parameter isn't valid. Review the available parameters for the API request.
HTTP Status Code: 400
- ResourceNotFoundException
-
The specified resource wasn't found.
HTTP Status Code: 400
- ServerException
-
These errors are usually caused by a server issue.
HTTP Status Code: 500
- UnsupportedFeatureException
-
The specified task isn't supported in this Region.
HTTP Status Code: 400
Examples
In the following example or examples, the Authorization header contents
(AUTHPARAMS
) must be replaced with an AWS Signature Version 4
signature. For more information, see Signature
Version 4 Signing Process in the
AWS General
Reference.
You only need to learn how to sign HTTP requests if you intend to
create them manually. When you use the AWS Command Line Interface
Example
This example request gets the protection status for a task.
Sample Request
POST / HTTP/1.1
Host: ecs.us-west-2.amazonaws.com
Accept-Encoding: identity
Content-Length:81
X-Amz-Target: AmazonEC2ContainerServiceV20141113.GetTaskProtection
X-Amz-Date: 20221102T190406Z
Content-Type: application/x-amz-json-1.1
Authorization: AUTHPARAMS
{
"cluster": "test-task-protection",
"tasks": [
"b8b1cf532d0e46ba8d44a40d1de16772"
]
}
Sample Response
HTTP/1.1 200 OK
Server: Server
Date: Wed, 02 Nov 2022 19:04:06 GMT
Content-Type: application/x-amz-json-1.1
Content-Length:177
Connection: keep-alive
x-amzn-RequestId: 123a4b56-7c89-01d2-3ef4-example5678f
{
"protectedTasks": [
{
"taskArn": "arn:aws:ecs:us-west-2:012345678910:task/b8b1cf532d0e46ba8d44a40d1de16772",
"protectionEnabled": true,
"expirationDate": 1667416437.0
}
],
"failures": []
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: