aws-nuke 란?
"nuke"는 "완전히 제거하다" 또는 "전멸시키다"라는 의미입니다.
AWS Nuke는 Amazon Web Services(AWS) 계정 내의 리소스를 일괄적으로 삭제하는 데 사용합니다.
특정 AWS Account 내의 모든 리소스를 완전히 정리하고 초기 상태로 만듭니다.
즉, 주로 계정을 정리하거나, 사용하지 않는 리소스를 정리할 때 사용합니다.
aws-nuke 설치
https://github.com/rebuy-de/aws-nuke/tree/main
GitHub - rebuy-de/aws-nuke: Nuke a whole AWS account and delete all its resources.
Nuke a whole AWS account and delete all its resources. - rebuy-de/aws-nuke
github.com
위 링크에서 aws-nuke를 다운로드 받을 수 있습니다.
aws-nuke 사용 방법
aws-nuke를 사용 방법은 크게 두 단계로 나뉩니다.
첫째, 설정 파일 작성을 작성합니다.
- 삭제할 리소스의 유형과 조건을 지정하는 설정 파일을 작성합니다.
https://github.com/rebuy-de/aws-nuke/tree/main/config
aws-nuke/config at main · rebuy-de/aws-nuke
Nuke a whole AWS account and delete all its resources. - rebuy-de/aws-nuke
github.com
예제 파일을 참고하여 자신의 환경에 알맞게 파일을 작성합니다.
필자의 경우, AWS IAM 사용자 외의 모든 리소스를 초기화 하고 싶어서 아래와 같이 작성하였습니다.
regions:
- "global"
- us-east-1
account-blocklist:
- "999999999"
resource-types:
excludes:
- IAMUser
- IAMGroup
- IAMGroupPolicy
- IAMGroupPolicyAttachment
- IAMInstanceProfile
- IAMInstanceProfileRole
- IAMLoginProfile
- IAMOpenIDConnectProvider
- IAMPolicy
- IAMRole
- IAMRolePolicy
- IAMRolePolicyAttachment
- IAMSAMLProvider
- IAMServerCertificate
- IAMServiceSpecificCredential
- IAMSigningCertificate
- IAMUser
- IAMUserAccessKey
- IAMUserGroupAttachment
- IAMUserPolicy
- IAMUserPolicyAttachment
accounts:
ACCOUT_ID_VALUE: {} // ACCOUNT_ID_VALUE에 ACCOUNT ID 값을 대체하여 넣어야 합니다.
둘째, AWS Nuke 실행합니다.
- 설정 파일을 기반으로 AWS Nuke를 실행하여 지정된 리소스를 삭제합니다.
- --no-dry-run 옵션을 빼면 삭제 대상의 리소스들을 확인할 수 있습니다.
- aws-nuke는 1번째로 삭제할 리소스를 스캔하고, 2번째에 실제로 삭제를 수행하므로 alias를 2번 입력해야 합니다.
aws-nuke -c config.yml --no-dry-run
'Dev > AWS' 카테고리의 다른 글
[AWS-SAA] 01. IAM과 AWS CLI에 대하여 (1) | 2024.09.04 |
---|---|
[AWS TechCamp] 기초부터 배우는 AWS 핵심 서비스로 웹 애플리케이션 구축하기 후기 및 요약 (1) | 2024.09.03 |
[AWS-SAA] 00. AWS 글로벌 인프라 구조 (압축 요약) (0) | 2024.08.29 |
AWS 프리티어 과금 안 되도록 사용하는 방법, 요약 (0) | 2024.05.21 |