Cleanup instructions
After trying this AWS Built-in solution, you may want to redeploy or remove it completely. In either case, this solution leaves certain resources as-is when you delete the stacks that are deployed. This behavior is working as designed to avoid deleting the history of data collections in your accounts.
You can clean up resources created this AWS Built-in solution to avoid incurring charges for resources created and avoid conflicts while redeploying the stack.
This section provides instructions to clean up the resources created by the AWS Built-in package.
1. Delete the CloudFormation stack
- Navigate to the AWS CloudFormation console.
- Choose the stack created by the AWS Built-in solution and delete it.
- Wait for the DELETE_COMPLETE status to confirm the stack deletion.
2. Delete resources created by the AWS Built-in solution
Automated cleanup (PLEASE REVIEW the manual cleanup steps below for resources that deleted by the automated cleanup)
Establish a session to the management account and run the following command:
cd ${REPO_ROOT}/scripts
python3 cleanup_config.py -C cleanup_config.json
Note-1: The automated cleanup script will not delete all the stacks. You still need to delete the stacks *CloudTrailStack*
and *GuardDutyStack*
manually (if exists).
Note-2: If you choose pDisableGuardDuty
as No
(default) during the installation of the solution, you need to delete the guardduty detector in all regions.
Manual cleanup.
In the management account:
- sra-gd-staging-
<account-id>
-<region>
- sra-cloudtrail-staging-
<account-id>
-<region>
- sra-helper-
<account-id>
-<region>
- sra-staging-
<account-id>
-<regions>
# Repeat for all regions where the solution is deployed.
- Delete Systems Manager parameters that start with below prefixes. Repeat for all active regions.
/sra/regions/
/sra/control-tower/
/sra/staging-s3-bucket-name
- Delete the AWS CloudWatch log groups that start with the following prefixes:
/sra/sra-org-trail
/aws/lambda/sra-codebuild-project-lambda
/aws/lambda/sra-guardduty-codebuild-project-lambda
- Delete a build project in AWS CodeBuild that start with the following prefixes.
sra-codebuild-project
- Delete AWS IAM roles that are listed below.
sra-execution
-
Delete a stack set with name
sra-stackset-execution-role
. -
Delete a stack with follwing stack names:
sra-common-prerequisites-staging-s3-bucket
*CloudTrailStack*
*GuardDutyStack*
- Delete GuardDuty detectors in all regions (Only if you choose
pDisableGuardDuty
asNo
during the installation of the solution).
In the log archive account:
- sra-guardduty-org-delivery-
<account-id>
-<region>
- sra-org-trail-logs-
<account-id>
-<region>
- Delete Systems Manager parameters that start with below prefixes. Repeat for all active regions.
/sra/regions/
/sra/control-tower/
- Delete the AWS CloudWatch log groups that start with the following prefixes:
/aws/lambda/sra-ct-s3
/aws/lambda/sra-gd-s3
/sra/gd/
- Delete AWS IAM roles that are listed below.
sra-execution
In the audit account:
- Delete AWS IAM roles that are listed below.
sra-execution