DeleteTaskDefinitions
Deletes one or more task definitions.
You must deregister a task definition revision before you delete it. For more information, see DeregisterTaskDefinition.
When you delete a task definition revision, it is immediately transitions from the
INACTIVE
to DELETE_IN_PROGRESS
. Existing tasks and
services that reference a DELETE_IN_PROGRESS
task definition revision
continue to run without disruption. Existing services that reference a
DELETE_IN_PROGRESS
task definition revision can still scale up or down
by modifying the service's desired count.
You can't use a DELETE_IN_PROGRESS
task definition revision to run new
tasks or create new services. You also can't update an existing service to reference a
DELETE_IN_PROGRESS
task definition revision.
A task definition revision will stay in DELETE_IN_PROGRESS
status until
all the associated tasks and services have been terminated.
When you delete all INACTIVE
task definition revisions, the task
definition name is not displayed in the console and not returned in the API. If a task
definition revisions are in the DELETE_IN_PROGRESS
state, the task
definition name is displayed in the console and returned in the API. The task definition
name is retained by Amazon ECS and the revision is incremented the next time you create a
task definition with that name.
Request Syntax
{
"taskDefinitions": [ "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.
- taskDefinitions
-
The
family
andrevision
(family:revision
) or full Amazon Resource Name (ARN) of the task definition to delete. You must specify arevision
.You can specify up to 10 task definitions as a comma separated list.
Type: Array of strings
Required: Yes
Response Syntax
{
"failures": [
{
"arn": "string",
"detail": "string",
"reason": "string"
}
],
"taskDefinitions": [
{
"compatibilities": [ "string" ],
"containerDefinitions": [
{
"command": [ "string" ],
"cpu": number,
"credentialSpecs": [ "string" ],
"dependsOn": [
{
"condition": "string",
"containerName": "string"
}
],
"disableNetworking": boolean,
"dnsSearchDomains": [ "string" ],
"dnsServers": [ "string" ],
"dockerLabels": {
"string" : "string"
},
"dockerSecurityOptions": [ "string" ],
"entryPoint": [ "string" ],
"environment": [
{
"name": "string",
"value": "string"
}
],
"environmentFiles": [
{
"type": "string",
"value": "string"
}
],
"essential": boolean,
"extraHosts": [
{
"hostname": "string",
"ipAddress": "string"
}
],
"firelensConfiguration": {
"options": {
"string" : "string"
},
"type": "string"
},
"healthCheck": {
"command": [ "string" ],
"interval": number,
"retries": number,
"startPeriod": number,
"timeout": number
},
"hostname": "string",
"image": "string",
"interactive": boolean,
"links": [ "string" ],
"linuxParameters": {
"capabilities": {
"add": [ "string" ],
"drop": [ "string" ]
},
"devices": [
{
"containerPath": "string",
"hostPath": "string",
"permissions": [ "string" ]
}
],
"initProcessEnabled": boolean,
"maxSwap": number,
"sharedMemorySize": number,
"swappiness": number,
"tmpfs": [
{
"containerPath": "string",
"mountOptions": [ "string" ],
"size": number
}
]
},
"logConfiguration": {
"logDriver": "string",
"options": {
"string" : "string"
},
"secretOptions": [
{
"name": "string",
"valueFrom": "string"
}
]
},
"memory": number,
"memoryReservation": number,
"mountPoints": [
{
"containerPath": "string",
"readOnly": boolean,
"sourceVolume": "string"
}
],
"name": "string",
"portMappings": [
{
"appProtocol": "string",
"containerPort": number,
"containerPortRange": "string",
"hostPort": number,
"name": "string",
"protocol": "string"
}
],
"privileged": boolean,
"pseudoTerminal": boolean,
"readonlyRootFilesystem": boolean,
"repositoryCredentials": {
"credentialsParameter": "string"
},
"resourceRequirements": [
{
"type": "string",
"value": "string"
}
],
"restartPolicy": {
"enabled": boolean,
"ignoredExitCodes": [ number ],
"restartAttemptPeriod": number
},
"secrets": [
{
"name": "string",
"valueFrom": "string"
}
],
"startTimeout": number,
"stopTimeout": number,
"systemControls": [
{
"namespace": "string",
"value": "string"
}
],
"ulimits": [
{
"hardLimit": number,
"name": "string",
"softLimit": number
}
],
"user": "string",
"volumesFrom": [
{
"readOnly": boolean,
"sourceContainer": "string"
}
],
"workingDirectory": "string"
}
],
"cpu": "string",
"deregisteredAt": number,
"ephemeralStorage": {
"sizeInGiB": number
},
"executionRoleArn": "string",
"family": "string",
"inferenceAccelerators": [
{
"deviceName": "string",
"deviceType": "string"
}
],
"ipcMode": "string",
"memory": "string",
"networkMode": "string",
"pidMode": "string",
"placementConstraints": [
{
"expression": "string",
"type": "string"
}
],
"proxyConfiguration": {
"containerName": "string",
"properties": [
{
"name": "string",
"value": "string"
}
],
"type": "string"
},
"registeredAt": number,
"registeredBy": "string",
"requiresAttributes": [
{
"name": "string",
"targetId": "string",
"targetType": "string",
"value": "string"
}
],
"requiresCompatibilities": [ "string" ],
"revision": number,
"runtimePlatform": {
"cpuArchitecture": "string",
"operatingSystemFamily": "string"
},
"status": "string",
"taskDefinitionArn": "string",
"taskRoleArn": "string",
"volumes": [
{
"configuredAtLaunch": boolean,
"dockerVolumeConfiguration": {
"autoprovision": boolean,
"driver": "string",
"driverOpts": {
"string" : "string"
},
"labels": {
"string" : "string"
},
"scope": "string"
},
"efsVolumeConfiguration": {
"authorizationConfig": {
"accessPointId": "string",
"iam": "string"
},
"fileSystemId": "string",
"rootDirectory": "string",
"transitEncryption": "string",
"transitEncryptionPort": number
},
"fsxWindowsFileServerVolumeConfiguration": {
"authorizationConfig": {
"credentialsParameter": "string",
"domain": "string"
},
"fileSystemId": "string",
"rootDirectory": "string"
},
"host": {
"sourcePath": "string"
},
"name": "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
- taskDefinitions
-
The list of deleted task definitions.
Type: Array of TaskDefinition 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
-
- InvalidParameterException
-
The specified parameter isn't valid. Review the available parameters for the API request.
HTTP Status Code: 400
- ServerException
-
These errors are usually caused by a server issue.
HTTP Status Code: 500
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 deletes the task definition named
Example-task-definition:1
.
Sample Request
POST / HTTP/1.1
Host: ecs.us-east-1.amazonaws.com
Accept-Encoding: identity
Content-Length: 25
X-Amz-Target: AmazonEC2ContainerServiceV20141113.DeleteTaskDefinitions
X-Amz-Date: 20150429T170952Z
Content-Type: application/x-amz-json-1.1
Authorization: AUTHPARAMS
{
"taskDefinitions": [
"Example-task-definition:1"
]
}
Sample Response
HTTP/1.1 200 OK
Server: Server
Date: Wed, 7 Dec 2022 17:09:54 GMT
Content-Type: application/x-amz-json-1.1
Content-Length: 211
Connection: keep-alive
x-amzn-RequestId: 123a4b56-7c89-01d2-3ef4-example5678f
{
"failures": [],
"taskDefinitions": [
{
"containerDefinitions": [
{
"command": [
"apt-get update; apt-get install stress; while true; do stress --cpu $(( RANDOM % 4 )) -t $(( RANDOM % 10 )); done"
],
"cpu": 50,
"entryPoint": [
"bash",
"-c"
],
"environment": [],
"essential": true,
"image": "ubuntu",
"memory": 100,
"mountPoints": [],
"name": "wave",
"portMappings": [],
"volumesFrom": []
}
],
"family": "cpu-wave",
"revision": 1,
"status": "DELETE_IN_PROGRESS",
"taskDefinitionArn": "arn:aws:ecs:us-east-1:012345678910:task-definition/Example-task-definition:1",
"volumes": []
}
]
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: