Clean Workshop Resources
Clean up AWS resources created by the AgentCore onboarding workshop.
Usage
- •
/clean-workshop— Clean all workshop resources (07, 06, 05, 03, 02) - •
/clean-workshop 02— Clean only step 02 (runtime) - •
/clean-workshop 02 03— Clean steps 02 and 03 - •
/clean-workshop 05 06 07— Clean steps 05, 06, and 07
Arguments
$ARGUMENTS contains space-separated step numbers to clean (e.g., 02 03 07).
If empty, clean ALL steps that have resources.
Steps with Cleanable Resources
Only these steps create AWS resources that need cleanup:
| Step | Directory | Resources | Config File |
|---|---|---|---|
| 02 | 02_runtime/ | Agent runtime, ECR repository, config files | .bedrock_agentcore.yaml |
| 03 | 03_memory/ | Memory instances (prefix: cost_estimator_memory) | None |
| 05 | 05_evaluation/ | Custom evaluator (name: cost_estimator_tool_usage) | None |
| 06 | 06_identity/ | OAuth2 provider, Cognito user pool/client/domain, runtime | inbound_authorizer.json |
| 07 | 07_gateway/ | Gateway targets, gateway, config files | outbound_gateway.json |
Dependency Order (CRITICAL)
Resources MUST be cleaned in reverse dependency order to avoid errors:
- •07_gateway first (depends on 06_identity)
- •06_identity second (depends on 02_runtime)
- •05_evaluation (independent)
- •03_memory (independent)
- •02_runtime last (other steps depend on it)
Execution
For each step to clean, run:
code
cd <project_root>/<step_directory> && uv run python clean_resources.py
Before cleaning each step:
- •Check if the config file exists (indicates resources were created)
- •If no config file, skip that step with a message
- •Run
clean_resources.pyfrom within the step directory (scripts use relative paths) - •Report success or failure for each step
Error handling:
- •If a step fails, log the error and continue with remaining steps
- •Report a summary at the end showing which steps succeeded/failed
- •Common errors: ResourceNotFoundException (already deleted), config file missing (never created)
Implementation
- •Parse
$ARGUMENTSto determine which steps to clean. If empty, use all:07 06 05 03 02 - •Sort the requested steps in correct cleanup order: 07, 06, 05, 03, 02
- •Create a task list tracking each step
- •For each step (in order):
a. Check if the step directory and config file exist
b. If resources exist, run
clean_resources.pyfrom that directory c. Mark task as completed - •Print a final summary