Destroy Method Using AWS CloudShell (When It's Difficult to Prepare Your Own Environment)¶
Overview¶
When deleting GenU, deletion is normally performed based on the deployed environment and configuration files. However, if you don't have these files due to one-click deployment or test deployments, you can quickly delete using this script.
Launch CloudShell¶
Launch CloudShell.
If you have the cdk.json or parameter.ts used during deployment, select "Upload file" from the "Actions" dropdown list at the top right of the CloudShell terminal to upload the files.
Download destroy.sh and Grant Execution Permission¶
Execute the following commands in CloudShell to download the destroy.sh script.
After downloading, grant execution permission to destroy.sh.
wget https://raw.githubusercontent.com/aws-samples/generative-ai-use-cases/refs/heads/main/destroy.sh -O destroy.sh
chmod +x destroy.sh
Execute destroy.sh¶
destroy.sh supports the following options.
-c, --cdk-context ... Path to the cdk.json file
-p, --parameter-file ... Path to the parameter.ts file
-e, --env ... Environment name (e.g., dev, prod)
-y, --yes ... Skip confirmation prompt
-h, --help ... Show this message
If cdk.json or parameter.ts is not specified, parameters will be estimated from the deployed GenU-related stacks and cdk.json will be created. The parameter estimation method follows setup-env.sh and estimates through the following steps:
- Search for deployed
GenerativeAiUseCasesStack* - Retrieve configuration information from CloudFormation outputs
- Automatically generate minimal cdk.json
- Destroy all related stacks
Destroy Examples¶
Execute destroy.sh with the following commands.
1. Auto-detect and Destroy¶
Automatically restores configuration from the deployed stack and destroys it. Use this method if you don't have configuration files.
./destroy.sh
If you have separate environments, set --env:
./destroy.sh --env dev
A confirmation prompt will be displayed. Enter yes to execute the destruction. If you want to skip confirmation and execute, run as follows:
./destroy.sh --env dev --yes
2. Destroy Using Customized cdk.json¶
If you have the cdk.json used during deployment:
./destroy.sh --cdk-context ~/cdk.json
3. Destroy Using Customized parameter.ts¶
If you have the parameter.ts used during deployment:
./destroy.sh --parameter-file ~/parameter.ts
4. Destroy with parameter.ts and Environment Specification¶
./destroy.sh --parameter-file ~/parameter.ts --env prod
Important Notes¶
- Destroy operations cannot be undone
- A confirmation prompt is always displayed before destruction (unless using the
--yesoption) - All related resources (S3 buckets, DynamoDB tables, Lambda functions, etc.) will be deleted
- If you need data backups, please obtain them before destruction