

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

# 상태 파일 손실 후 AWS Account Factory for Terraform(AFT) 리소스를 안전하게 정리
<a name="clean-up-aft-resources-safely-after-state-file-loss"></a>

*Gokendra Malviya, Amazon Web Services*

## 요약
<a name="clean-up-aft-resources-safely-after-state-file-loss-summary"></a>

 AWS Account Factory for Terraform(AFT)을 사용하여 AWS Control Tower 환경을 관리하면 AFT는 Terraform 상태 파일을 생성하여 Terraform에서 생성한 리소스의 상태 및 구성을 추적합니다. Terraform 상태 파일이 손실되면 리소스 관리 및 정리에 상당한 문제가 발생할 수 있습니다. 이 패턴은 AWS Control Tower 환경의 무결성을 유지하면서 AFT 관련 리소스를 안전하게 식별하고 제거하는 체계적인 접근 방식을 제공합니다.

이 프로세스는 원래 상태 파일 참조가 없더라도 모든 AFT 구성 요소를 적절하게 제거하도록 설계되었습니다. 이 프로세스는 환경에서 AFT를 성공적으로 다시 설정하고 재구성할 수 있는 명확한 경로를 제공하여 AWS Control Tower 운영 중단을 최소화합니다.

AFT에 대한 자세한 내용은 [AWS Control Tower 설명서](https://docs.aws.amazon.com/controltower/latest/userguide/taf-account-provisioning.html)를 참조하세요.

## 사전 조건 및 제한 사항
<a name="clean-up-aft-resources-safely-after-state-file-loss-prereqs"></a>

**사전 조건 **
+ [AFT 아키텍처](https://docs.aws.amazon.com/controltower/latest/userguide/aft-architecture.html)에 대한 명확한 이해
+ 다음 계정에 대한 관리자 액세스:
  + AFT 관리 계정
  + AWS Control Tower 관리 계정
  + 로그 아카이브 계정
  + 감사 계정
+ 서비스 제어 정책(SCPs AFT 관련 리소스의 삭제를 차단하는 제한 또는 제한이 포함되어 있지 않은지 확인합니다.

**제한 사항 **
+ 이 프로세스는 리소스를 효과적으로 정리할 수 있지만 손실된 상태 파일을 복구할 수 없으며 일부 리소스는 수동 식별이 필요할 수 있습니다.
+ 정리 프로세스 기간은 환경의 복잡성에 따라 달라지며 몇 시간이 걸릴 수 있습니다.
+ 이 패턴은 AFT 버전 1.12.2로 테스트되었으며 다음 리소스를 삭제합니다. 다른 버전의 AFT를 사용하는 경우 추가 리소스를 삭제해야 할 수 있습니다.    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html)

**중요**  
이 패턴의 단계에 의해 삭제된 리소스는 복구할 수 없습니다. 이 단계를 수행하기 전에 리소스 이름을 주의 깊게 확인하고 AFT에서 생성했는지 확인합니다.

## 아키텍처
<a name="clean-up-aft-resources-safely-after-state-file-loss-architecture"></a>

다음 다이어그램은 이 고급 워크플로를 보여 줍니다. AFT는 AWS Control Tower에서 계정을 프로비저닝하고 사용자 지정하는 데 도움이 되는 Terraform 파이프라인을 설정합니다. AFT는 GitOps 모델을 따라 계정 프로비저닝 프로세스를 자동화합니다 AWS Control Tower. AFT를 사용하여 계정 요청 Terraform 파일을 생성하고 계정 프로비저닝을 위한 AFT 워크플로를 트리거하는 입력을 가져옵니다. 계정 프로비저닝이 완료되면 AFT는 추가 사용자 지정 단계를 자동으로 실행할 수 있습니다.

![\[AFT 구성 요소 및 상위 수준 워크플로.\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/1342c0a6-4b07-46df-a063-ceab2e2f83c8/images/3e0cae87-20ef-4fcc-aacf-bb450844ac56.png)


이 아키텍처에서,
+ **AWS Control Tower 관리 계정**은 AWS Control Tower 서비스 전용 AWS 계정 입니다. 이를 일반적으로 *AWS 지급인 계정* 또는 *AWS Organizations 관리 계정*이라고도 합니다.
+ **AFT 관리 계정**은 AFT 관리 작업 전용 AWS 계정 입니다. 이는 조직의 관리 계정과 다릅니다.
+ **판매 계정**은 선택한 모든 기준 구성 요소와 컨트롤을 AWS 계정 포함하는 입니다. AFT는 AWS Control Tower 를 사용하여 새 계정을 벤딩합니다.

이 아키텍처에 대한 자세한 내용은 AWS Control Tower 워크숍의 [AFT 소개를](https://catalog.workshops.aws/control-tower/en-US/customization/aft) 참조하세요.

## 도구
<a name="clean-up-aft-resources-safely-after-state-file-loss-tools"></a>

**AWS 서비스**
+ [AWS Control Tower](https://docs.aws.amazon.com/controltower/latest/userguide/what-is-control-tower.html)는 규범적 모범 사례에 따라 AWS 다중 계정 환경을 설정하고 관리하는 데 도움이 됩니다.
+ [AWS Account Factory for Terraform(AFT)](https://docs.aws.amazon.com/controltower/latest/userguide/taf-account-provisioning.html)은 계정과 리소스를 프로비저닝하고 사용자 지정하는 데 도움이 되는 Terraform 파이프라인을 설정합니다 AWS Control Tower.
+ [AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html)를 사용하면 AWS 리소스를 확장하고 확장할 때 환경을 중앙에서 관리하고 관리할 수 있습니다. Organizations를 사용하면 계정을 만들고 리소스를 할당하며, 계정을 그룹화하여 워크플로를 구성하고, 거버넌스를 위해 정책을 적용하고, 모든 계정에 대해 단일 결제 방법을 사용하여 청구를 간소화할 수 있습니다.
+ [AWS Identity and Access Management (IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html)는 AWS 리소스에 대한 액세스를 인증하고 사용할 권한이 있는 사용자를 제어하여 리소스에 대한 액세스를 안전하게 관리하는 데 도움이 됩니다. 이 패턴에는 IAM 역할 및 권한이 필요합니다.

**기타 도구**
+ [Terraform](https://www.terraform.io/)은 HashiCorp의 코드형 인프라(IaC) 도구로, 클라우드 및 온프레미스 리소스를 생성하고 관리하는 데 도움이 됩니다.

## 모범 사례
<a name="clean-up-aft-resources-safely-after-state-file-loss-best-practices"></a>
+ 자세한 AWS Control Tower내용은 AWS Control Tower 설명서의 [AWS Control Tower 관리자 모범 사례를 참조하세요](https://docs.aws.amazon.com/controltower/latest/userguide/best-practices.html).
+ 자세한 내용은 IAM 설명서의 [보안 모범 사례](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)를 참조하세요.

## 에픽
<a name="clean-up-aft-resources-safely-after-state-file-loss-epics"></a>

### AFT Management 계정에서 AFT 리소스 삭제
<a name="delete-aft-resources-in-the-aft-management-account"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| AFT 태그로 식별되는 리소스를 삭제합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 
|  IAM 역할 삭제 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 
|  AWS Backup 백업 볼트를 삭제합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 
| Amazon CloudWatch 리소스 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 
|  AWS KMS 리소스를 삭제합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 

### 로그 아카이브 계정에서 AFT 리소스 삭제
<a name="delete-aft-resources-in-the-log-archive-account"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
|  S3 버킷 삭제 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 
|  IAM 역할 삭제 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 

### 감사 계정에서 AFT 리소스 삭제
<a name="delete-aft-resources-in-the-audit-account"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
|  IAM 역할 삭제 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 

### AWS Control Tower 관리 계정에서 AFT 리소스 삭제
<a name="delete-aft-resources-in-the-ctower-management-account"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
|  IAM 역할 삭제 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 
| EventBridge 규칙을 삭제합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | AWS 관리자, AWS DevOps, DevOps 엔지니어 | 

## 문제 해결
<a name="clean-up-aft-resources-safely-after-state-file-loss-troubleshooting"></a>


| 문제 | Solution | 
| --- | --- | 
| 인터넷 게이트웨이 분리에 실패했습니다. | **AFT** 태그로 식별되는 리소스를 삭제하는 동안 인터넷 게이트웨이를 분리하거나 삭제할 때이 문제가 발생하면 먼저 VPC 엔드포인트를 삭제해야 합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | 
| 지정된 CloudWatch 쿼리를 찾을 수 없습니다. | AFT에서 생성한 CloudWatch 쿼리를 찾을 수 없는 경우 다음 단계를 따릅니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/clean-up-aft-resources-safely-after-state-file-loss.html) | 

## 관련 리소스
<a name="clean-up-aft-resources-safely-after-state-file-loss-resources"></a>
+ AFT
  + [GitHub 리포지토리](https://github.com/aws-ia/terraform-aws-control_tower_account_factory)
  + [워크숍](https://catalog.workshops.aws/control-tower/en-US/customization/aft)
  + [설명서](https://docs.aws.amazon.com/controltower/latest/userguide/aft-getting-started.html)
+ [AWS Control Tower 설명서](https://docs.aws.amazon.com/controltower/latest/userguide/getting-started-with-control-tower.html)

## 추가 정보
<a name="clean-up-aft-resources-safely-after-state-file-loss-additional"></a>

CloudWatch Logs Insights 대시보드에서 AFT 쿼리를 보려면 다음 스크린샷과 같이 오른쪽 상단 모서리에서 **저장된 쿼리 및 샘플 쿼리** 아이콘을 선택합니다.

![\[CloudWatch Logs Insights 대시보드에서 AFT 쿼리에 액세스합니다.\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/1342c0a6-4b07-46df-a063-ceab2e2f83c8/images/255d4032-738b-4600-9084-9684d2e9a328.png)
