1. terraform destroy 명령어 소개
terraform destroy는 Terraform으로 관리되는 인프라 리소스를 제거하는 명령어입니다- 현재 Terraform 프로젝트에서 관리하는 모든 리소스를 종료합니다
- 프로젝트 외부의 다른 리소스는 영향받지 않습니다
경고
이 명령어는 되돌릴 수 없는 작업을 수행하므로 매우 신중하게 사용해야 합니다.
2. 실행 계획 검토
2.1 삭제 계획 출력 예시
$ terraform destroy
Terraform will perform the following actions:
# aws_instance.app_server will be destroyed
- resource "aws_instance" "app_server" {
- ami = "ami-08d70e59c07c61a3a" -> null
- arn = "arn:aws:ec2:us-west-2:561656980159:instance/i-0fd4a35969bd21710" -> null
...
}
Plan: 0 to add, 0 to change, 1 to destroy.
2.2 계획 해석 방법
-기호: 삭제될 리소스 표시-> null: 현재 값이 삭제되어 null이 될 것임을 의미- 요약 정보: 삭제될 리소스 수 표시
3. 삭제 프로세스
3.1 삭제 확인
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
- 안전성을 위해
yes만 허용 - 신중한 검토 후 확인 필요
3.2 삭제 진행 과정
aws_instance.app_server: Destroying... [id=i-0fd4a35969bd21710]
aws_instance.app_server: Still destroying... [id=i-0fd4a35969bd21710, 10s elapsed]
aws_instance.app_server: Destruction complete after 31s
Destroy complete! Resources: 1 destroyed.
- 실시간 진행 상황 표시
- 리소스별 삭제 시간 표시
- 최종 삭제 결과 요약