

Doc AWSSDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. [AWS](https://github.com/awsdocs/aws-doc-sdk-examples) 

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# AWSSDK 또는 CLI와 `DeregisterTaskDefinition` 함께 사용
<a name="ecs_example_ecs_DeregisterTaskDefinition_section"></a>

다음 코드 예제는 `DeregisterTaskDefinition`의 사용 방법을 보여 줍니다.

작업 예시는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.
+  [컨테이너 서비스 연결 구성](ecs_example_ecs_ServiceConnect_085_section.md) 
+  [서버리스 시작 유형에 대한 컨테이너 작업 생성](ecs_example_ecs_GettingStarted_086_section.md) 
+  [가상 머신 인스턴스에 대한 컨테이너 서비스 생성](ecs_example_ecs_GettingStarted_018_section.md) 
+  [Amazon ECS 기본 사항 알아보기](ecs_example_ecs_Scenario_section.md) 

------
#### [ CLI ]

**AWS CLI**  
**작업 정의를 등록 취소하려면**  
다음 `deregister-task-definition` 예시에서는 기본 리전에서 `curler` 작업 정의의 첫 번째 개정을 등록 취소합니다.  

```
aws ecs deregister-task-definition --task-definition {{curler:1}}
```
결과 출력에서 작업 정의 상태는 `INACTIVE`를 표시합니다.  

```
{
    "taskDefinition": {
        "status": "INACTIVE",
        "family": "curler",
        "volumes": [],
        "taskDefinitionArn": "arn:aws:ecs:us-west-2:123456789012:task-definition/curler:1",
        "containerDefinitions": [
            {
                "environment": [],
                "name": "curler",
                "mountPoints": [],
                "image": "curl:latest",
                "cpu": 100,
                "portMappings": [],
                "entryPoint": [],
                "memory": 256,
                "command": [
                    "curl -v http://example.com/"
                ],
                "essential": true,
                "volumesFrom": []
            }
        ],
        "revision": 1
    }
}
```
자세한 내용은 *Amazon ECS 개발자 안내서*의 [Amazon ECS 태스크 정의](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeregisterTaskDefinition](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/deregister-task-definition.html) 섹션을 참조하세요.

------
#### [ Python ]

**SDK for Python(Boto3)**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예제 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/ecs#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
class EcsWrapper:
    """Encapsulates Amazon ECS operations."""

    def __init__(self, ecs_client: BaseClient):
        """
        Initializes the EcsWrapper with an ECS client.

        :param ecs_client: A Boto3 Amazon ECS client. Boto3 clients are created
            by the ``boto3.client`` factory function and are instances of
            ``botocore.client.BaseClient``, which is the correct type to
            annotate here (``boto3.client`` itself is a function, not a type).
        """
        self.ecs_client = ecs_client

    @classmethod
    def from_client(cls) -> "EcsWrapper":
        """Creates an EcsWrapper using a default Boto3 ECS client."""
        ecs_client = boto3.client("ecs")
        return cls(ecs_client)


    def deregister_task_definition(self, task_definition: str) -> Dict[str, Any]:
        """
        Deregisters a task definition.

        :param task_definition: The family:revision of the task definition.
        :return: The deregistered task definition details.
        :raises ClientError: If the request fails (e.g., InvalidParameterException).
        """
        try:
            response = self.ecs_client.deregister_task_definition(
                taskDefinition=task_definition,
            )
            task_def = response["taskDefinition"]
            logger.info(
                "Deregistered task definition '%s' (status: %s)",
                task_def["taskDefinitionArn"],
                task_def["status"],
            )
            return task_def
        except ClientError as err:
            if err.response["Error"]["Code"] == "InvalidParameterException":
                logger.error(
                    "Invalid parameter when deregistering task definition '%s': %s",
                    task_definition,
                    err.response["Error"]["Message"],
                )
            raise
```
+  API 세부 정보는 SDK for Python (Boto3) API 참조의 [DeregisterTaskDefinition](https://docs.aws.amazon.com/goto/boto3/ecs-2014-11-13/DeregisterTaskDefinition)을 참조하세요. *AWS* 

------