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.
Parameters:
-
task_definitions
(StringList)
–
The family and revision (family:revision) or full Amazon Resource Name (ARN) of the task definition to delete. You must specify a revision.
You can specify up to 10 task definitions as a comma separated list.
Raises:
-
AccessDeniedException
–
You don't have authorization to perform the requested action.
-
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.
-
InvalidParameterException
–
The specified parameter isn't valid. Review the available parameters for the API request.
For more information about service event errors, see Amazon ECS service event messages.
-
ServerException
–
These errors are usually caused by a server issue.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To delete a task definition that has been deregistered
This example deletes a specified deregistered task definition.
>>> await client.delete_task_definitions(task_definitions=['Example-task-definition:1'])
Source code in docs_src/capo_ecs/_services/async_ecs.py
| async def delete_task_definitions(
self,
task_definitions: "capo_ecs.types.string_list.StringList",
*,
config_overrides: Optional[AsyncECSClientConfig] = None,
) -> (
"capo_ecs.types.delete_task_definitions_response.DeleteTaskDefinitionsResponse"
):
"""<p>Deletes one or more task definitions.</p> <p>You must deregister a task definition revision before you delete it. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeregisterTaskDefinition.html">DeregisterTaskDefinition</a>.</p> <p>When you delete a task definition revision, it is immediately transitions from the <code>INACTIVE</code> to <code>DELETE_IN_PROGRESS</code>. Existing tasks and services that reference a <code>DELETE_IN_PROGRESS</code> task definition revision continue to run without disruption. Existing services that reference a <code>DELETE_IN_PROGRESS</code> task definition revision can still scale up or down by modifying the service's desired count.</p> <p>You can't use a <code>DELETE_IN_PROGRESS</code> task definition revision to run new tasks or create new services. You also can't update an existing service to reference a <code>DELETE_IN_PROGRESS</code> task definition revision.</p> <p> A task definition revision will stay in <code>DELETE_IN_PROGRESS</code> status until all the associated tasks and services have been terminated.</p> <p>When you delete all <code>INACTIVE</code> 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 <code>DELETE_IN_PROGRESS</code> 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.</p>
Args:
task_definitions: <p>The <code>family</code> and <code>revision</code> (<code>family:revision</code>) or full Amazon Resource Name (ARN) of the task definition to delete. You must specify a <code>revision</code>.</p> <p>You can specify up to 10 task definitions as a comma separated list.</p>
Raises:
capo_ecs.errors.access_denied_exception.AccessDeniedException: <p>You don't have authorization to perform the requested action.</p>
capo_ecs.errors.client_exception.ClientException: <p>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.</p>
capo_ecs.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter isn't valid. Review the available parameters for the API request.</p> <p>For more information about service event errors, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages-list.html">Amazon ECS service event messages</a>. </p>
capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To delete a task definition that has been deregistered
This example deletes a specified deregistered task definition.
>>> await client.delete_task_definitions(task_definitions=['Example-task-definition:1'])
"""
async def _handler(
req: "AsyncOperationRequest[capo_ecs.types.delete_task_definitions_request.DeleteTaskDefinitionsRequest]",
) -> AsyncOperationResponse[
"capo_ecs.types.delete_task_definitions_response.DeleteTaskDefinitionsResponse"
]:
import capo_ecs._operations.amazon_ec2_container_service_v20141113.delete_task_definitions
(
output,
http_response,
) = await capo_ecs._operations.amazon_ec2_container_service_v20141113.delete_task_definitions.async_delete_task_definitions(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
def _redact_output(
output: "capo_ecs.types.delete_task_definitions_response.DeleteTaskDefinitionsResponse",
) -> dict[str, Any]:
import capo_ecs.types.delete_task_definitions_response
return capo_ecs.types.delete_task_definitions_response.redact_sensitive(
output
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("DeleteTaskDefinitions", redact_output=_redact_output),
)
input_: capo_ecs.types.delete_task_definitions_request.DeleteTaskDefinitionsRequest = {
"task_definitions": task_definitions
}
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|