AgentSkillsCN

clean-workshop

清理 AgentCore 研讨会所创建的 AWS 资源。适用于希望拆除、清理或移除研讨会资源时使用。

SKILL.md
--- frontmatter
name: clean-workshop
description: Clean up AWS resources created by the AgentCore workshop. Use when someone wants to tear down, clean up, or remove workshop resources.
allowed-tools: Bash, Read, Glob, Grep, Task, TaskCreate, TaskUpdate, TaskList

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:

StepDirectoryResourcesConfig File
0202_runtime/Agent runtime, ECR repository, config files.bedrock_agentcore.yaml
0303_memory/Memory instances (prefix: cost_estimator_memory)None
0505_evaluation/Custom evaluator (name: cost_estimator_tool_usage)None
0606_identity/OAuth2 provider, Cognito user pool/client/domain, runtimeinbound_authorizer.json
0707_gateway/Gateway targets, gateway, config filesoutbound_gateway.json

Dependency Order (CRITICAL)

Resources MUST be cleaned in reverse dependency order to avoid errors:

  1. 07_gateway first (depends on 06_identity)
  2. 06_identity second (depends on 02_runtime)
  3. 05_evaluation (independent)
  4. 03_memory (independent)
  5. 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:

  1. Check if the config file exists (indicates resources were created)
  2. If no config file, skip that step with a message
  3. Run clean_resources.py from within the step directory (scripts use relative paths)
  4. 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

  1. Parse $ARGUMENTS to determine which steps to clean. If empty, use all: 07 06 05 03 02
  2. Sort the requested steps in correct cleanup order: 07, 06, 05, 03, 02
  3. Create a task list tracking each step
  4. For each step (in order): a. Check if the step directory and config file exist b. If resources exist, run clean_resources.py from that directory c. Mark task as completed
  5. Print a final summary