teardown-agent-aca-aws
Skill12 starsChanged 7 months agoMITView on GitHub
AI-led teardown of the AWS Bedrock sample agent deployment on Azure Container Apps created by deploy-agent-aca-aws. Use when the user wants to delete the AWS sample ACA deployment, clean up the resource group, remove the AWS IAM role + OIDC provider, delete the intermediary Entra app, or optionally delete the Blueprint / Agent Identity / Client SPA. Defaults to DRY-RUN and keeps Entra/AWS objects unless the user explicitly opts in. NOT for local docker-compose (no cloud resources to delete) and NOT for GCP (pending).
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- n8n/.github/copilot-instructions.mdCopilot instructions
- deploy-agent-aca-awsSkill
- deploy-agent-aca-devSkill
- entra-agent-id-setupSkill
- teardown-agent-aca-devSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
Dry-run by default: Every script defaults to DRY_RUN=1 — it prints the commands it would run and exits.
- Distinctive: line 29
Entra and AWS objects are opt-in: Default behavior deletes only the Azure resource group.
- Very specific: line 56
Do not proceed without a y.
- Very specific: line 60
If the Agent Identity (AGENT_CLIENT_ID) will be kept, revoke the Graph OAuth2 consent so a future redeploy starts from a clean state:
- Distinctive: line 96
Ask the user once more per object.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Teardown — AWS Bedrock Agent on Azure Container Apps (AI-Led)
Reverses the deploy-agent-aca-aws skill. Deletes Azure resources, the AWS IAM role and OIDC provider, and (opt-in) the Entra objects created along the way.
Paired with: deploy-agent-aca-aws. Uses the same /tmp/deploy-vars.sh produced by that skill.
When to Use
- User says: "tear down the AWS ACA deployment", "delete the Azure resources for the AWS sample", "clean up after the demo"
- User wants to re-run the deploy skill from a clean state
- User is ending a demo and needs to remove billable resources
Do NOT Use When
- Local dev —
sidecar/dev/runs in docker-compose;docker compose down -vis enough - Shared / long-lived tenants — do not run this against a tenant where other teams may own the Blueprint or Client SPA. Confirm ownership with the user first.
- Hardened / long-lived deployments — this skill assumes a throwaway demo deployment.
Safety posture
This skill is destructive. To prevent accidents:
- Dry-run by default. Every script defaults to
DRY_RUN=1— it prints the commands it would run and exits. The user must explicitly setDRY_RUN=0to actually delete. - Entra and AWS objects are opt-in. Default behavior deletes only the Azure resource group. Entra apps (Agent Identity, Blueprint, Client SPA, Intermediary) and AWS objects (IAM role, OIDC provider) are preserved unless the user sets
DELETE_ENTRA=1orDELETE_AWS=1. - Confirm the tenant + subscription + resource group with the user before running anything. The user has multiple Azure accounts (see user memory).
- Never auto-delete Blueprints — Blueprints may be shared across agents. If
DELETE_ENTRA=1, ask the user one more time: "Delete Blueprint<id>? y/N".
Prerequisites
/tmp/deploy-vars.shfrom the original deployment (containsRG,STS_APP_ID,AWS_ROLE_NAME,AWS_ACCOUNT_ID,TENANT_ID, etc.). If missing, reconstruct the minimum set with the user (at leastSUBSCRIPTION_ID,RG).azlogged in to the same tenant and subscription that owns the RG.awsconfigured for the same account that owns the role (only ifDELETE_AWS=1).- Graph role sufficient to delete Entra apps (only if
DELETE_ENTRA=1):Application Administratoror higher.
Procedure
Step 0 — Confirm scope with the user
Print the current settings and wait for explicit confirmation:
Teardown plan (AWS):
Subscription: $SUBSCRIPTION_ID
Resource group: $RG (WILL be deleted)
Delete AWS IAM role + OIDC: $DELETE_AWS
Delete Entra objects: $DELETE_ENTRA
Dry run: $DRY_RUN
Proceed? [y/N]Do not proceed without a y.
Step 1 — Revoke OAuth consent grants on the Agent SP (optional but recommended)
If the Agent Identity (AGENT_CLIENT_ID) will be kept, revoke the Graph OAuth2 consent so a future redeploy starts from a clean state:
AGENT_SP_OID=$(az ad sp show --id "$AGENT_CLIENT_ID" --query id -o tsv 2>/dev/null)
if [[ -n "$AGENT_SP_OID" ]]; then
az rest --method GET \
--uri "https://graph.microsoft.com/v1.0/oauth2PermissionGrants?\$filter=clientId eq '$AGENT_SP_OID'" \
--query 'value[].id' -o tsv | while read -r g; do
az rest --method DELETE --uri "https://graph.microsoft.com/v1.0/oauth2PermissionGrants/$g"
done
fiThis is idempotent — if the SP or the grants are gone already, it no-ops.
Step 2 — Delete the Azure resource group
This removes the Container App, ACA environment, ACR (with all images), Log Analytics workspace, and the user-assigned managed identity in one shot:
az group delete --name "$RG" --yes --no-waitNote: FICs on the Blueprint and Intermediary Entra apps that point at the deleted MI's object ID become orphaned but inert. They are cleaned up in Step 4 if DELETE_ENTRA=1, or can be left in place — they cannot be re-used since the MI they reference no longer exists.
Step 3 — Delete AWS objects (opt-in: DELETE_AWS=1)
aws iam delete-role-policy --role-name "$AWS_ROLE_NAME" --policy-name BedrockInvokeOnly 2>/dev/null || true
aws iam delete-role --role-name "$AWS_ROLE_NAME" 2>/dev/null || true
aws iam delete-open-id-connect-provider \
--open-id-connect-provider-arn "arn:aws:iam::${AWS_ACCOUNT_ID}:oidc-provider/sts.windows.net/${TENANT_ID}/" 2>/dev/null || trueStep 4 — Delete Entra objects (opt-in: DELETE_ENTRA=1)
Ask the user once more per object. Delete in this order to avoid broken references:
- Intermediary app (
STS_APP_ID) — safe to delete, created purely for AWS federation. - Client SPA (
CLIENT_SPA_APP_ID) — safe if no other agent reuses it. - Agent Identity — delete via Agent ID portal or Graph (
DELETE /agentIdentities/{id}). - Blueprint (
BLUEPRINT_APP_ID) — ASK AGAIN. Blueprints are often shared.
az ad app delete --id "$STS_APP_ID" 2>/dev/null || true
az ad app delete --id "$CLIENT_SPA_APP_ID" 2>/dev/null || true
# Agent + Blueprint: prompt explicitly, then call GraphStep 5 — Verify
az group exists --name "$RG" # expect: false
aws iam get-role --role-name "$AWS_ROLE_NAME" 2>&1 | head -1 # expect: NoSuchEntity (if DELETE_AWS=1)
az ad app show --id "$STS_APP_ID" 2>&1 | head -1 # expect: not found (if DELETE_ENTRA=1)Orchestrator
The single-entry-point script is scripts/teardown-aca-aws.sh. It reads /tmp/deploy-vars.sh, enforces dry-run by default, prompts at every destructive boundary, and executes steps 1–5 in order.
# Dry run (default)
bash .claude/skills/teardown-agent-aca-aws/scripts/teardown-aca-aws.sh
# Real teardown, Azure only
DRY_RUN=0 bash .claude/skills/teardown-agent-aca-aws/scripts/teardown-aca-aws.sh
# Full teardown
DRY_RUN=0 DELETE_AWS=1 DELETE_ENTRA=1 \
bash .claude/skills/teardown-agent-aca-aws/scripts/teardown-aca-aws.shCommon failure modes
| Symptom | Cause | Fix |
az group delete hangs on soft-deleted Key Vault | RG contained a KV with purge protection | Purge separately: az keyvault purge --name <kv> |
DeleteConflict on IAM role | Role still attached to an instance profile or has inline policies | The script deletes BedrockInvokeOnly first; if extra policies exist, list + detach them manually |
Authorization_RequestDenied on az ad app delete | Signing-in user lacks Application Administrator on the app | Have the app owner run it, or elevate via PIM |
| FIC cleanup leaves orphaned entries on Blueprint | MI already deleted by az group delete | Inert — delete via az ad app federated-credential list/delete if cosmetic cleanup matters |
| OIDC provider already in use by another role | Shared across multiple role bindings in the same account | Do NOT delete the OIDC provider; leave DELETE_AWS=0 or delete only the role |
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

