Note 2021.09.20: Mistake! I delete manually also default thinks and I had to search a create again!!
Note: Delete all Cloud Resources In AWS if you are using to learn. Not in Productivity!!
Method 1. Nuke Your AWS Cloud
Combination of articles that helped to try to delete all content in AWS:
- A. https://www.maketecheasier.com/install-wget-mac/
- B. https://collabnix.com/2-minutes-to-clean-up-your-aws-resources/
Do all needed in MacBook and run Nuke:
1. Ensure that you have aws configure configured in MacBook
1.a. Download and install it using Homebrew
silvia ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
!!! Xcode is included in this installation
1.b. Install wget
silvia ~ % brew install wget
2. Run cloud-nuke
silvia ~ % sudo cloud-nuke aws Password: INFO[2021-09-04T17:39:38+03:00] The following resource types will be nuked: INFO[2021-09-04T17:39:38+03:00] - ami INFO[2021-09-04T17:39:38+03:00] - asg …… /usr/local/go/src/runtime/asm_amd64.s:1357 (0x1059fe1) error="Encountered multiple errors:\nAccessDenied: Access Denied\n\tstatus code: 403, request id: 66C2V18BQM63MVBT, host id: sBZQSh5SGutqXr7GNqZuaEb89CtHLKOFGBmBt0y5ApeT6vAl9bvjNAio0sr9Nr6i5+4r9XziZtc=" silvia ~ %
3. Searching and finding problem in IAM Roles:
3.a. Errors during deleting roles.
- Role AWSServiceRoleForConfig not deleted.
- One or more ConfigurationRecorders are using this role.
3.b. Errors during deleting roles.
- Role AWSServiceRoleForOrganizations not deleted.
- You can’t remove the service-linked role from accounts in an organization with All Features enabled.
3.c. Errors during deleting roles.
- Role AWSServiceRoleForSSO not deleted.
- There is an SSO instance with master account 317942813033, Please delete the SSO instance first before requesting to delete the SLR.
4. MAYBE the problem is because connection to AWS through CLI was based on user key access not the root. Next I try to connect from MacBook to AWS using root access.
5. Search to run again cloud-nuke in root
- 5.a. Managed to delete S3, deleting first policy for this S3
- 5.b. Run again sudo cloud-nuke aws
- 5.c. No problem, maybe delete completely base on this process
6. Run again sudo cloud-nuke aws (Connected to CLI based on root Key Access)
… INFO[2021-09-05T05:55:22+03:00] Checking region [14/17]: us-east-1 INFO[2021-09-05T05:55:29+03:00] Checking region [15/17]: us-east-2 INFO[2021-09-05T05:55:35+03:00] Checking region [16/17]: us-west-1 INFO[2021-09-05T05:55:42+03:00] Checking region [17/17]: us-west-2 INFO[2021-09-05T05:55:51+03:00] Nothing to nuke, you're all good! silvia ~ %
7. Not all things deleted in AWS. IAM Roles still there included things explain for error!!!
Method 2. Delete things remained in AWS Cloud
8. IAM Roles problem to delete => are still there
8.a. Errors during deleting roles.
- Role AWSServiceRoleForConfig not deleted.
- One or more ConfigurationRecorders are using this role.
8.a.1. To delete the configuration recorder
silvia ~ % aws configservice delete-configuration-recorder --configuration-recorder-name default
8.a.2. Delete role successfully.
Role deleted AWSServiceRoleForConfig
8.b. Errors during deleting roles.
- Role AWSServiceRoleForOrganizations not deleted.
- You can’t remove the service-linked role from accounts in an organization with All Features enabled.
8.b.1. To remove the management account from an organization and delete the organization
- Sign in to the AWS Organizations console. You must sign in as an IAM user, assume an IAM role, or sign in as the root user (not recommended) in the organization’s management account.
- Before you can delete the organization, you must first remove all accounts from the organization. For more information, see Removing a member account from your organization.
- Navigate to the Settings page, and then choose Delete organization.
- In the Delete organization confirmation dialog box, enter the organization’s ID which is displayed in the line above the text box. Then, choose Delete organization.
- (Optional) If you also want to close the management account, you can follow the steps at Closing an AWS account.
Source: https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_delete.html
8.c. Errors during deleting roles.
- Role AWSServiceRoleForSSO not deleted.
- There is an SSO instance with master account 317942813033, Please delete the SSO instance first before requesting to delete the SLR.
8.c.1. Find info and delete SSO: https://aws.amazon.com/blogs/security/how-to-delegate-management-of-identity-in-aws-single-sign-on/
8.c.2. Delete Roles Successfully.
I hope is all deleted!!!
Note 2021.09.20: Mistake! I delete also default thinks and I had to search a create again!!