1# Clears the floci local emulator: enumerates every LOCALLY EMULATED AWS
2# resource (`--local`) and deletes it. Only providers registered with both a
3# live and a local implementation participate, so the real cloud is never
4# touched and no cloud credentials are needed.
5#
6# `--include 'AWS.*'` keeps the run to floci. Drop it to also sweep the
7# Cloudflare local runtime (workerd instances alive in this process — always
8# empty from a fresh CLI invocation, so it just costs a build).
9#
10# --- What is spared, and why -----------------------------------------------
11#
12# The emulator, like a real account, has always-present singletons. Deleting
13# them either fails or is a no-op that re-enumerates on the next run, so a
14# run would never converge to "nothing to delete":
15#
16# AWS.ApiGateway.Account account-level settings object; get-account always
17# answers, so it lists forever
18# AwsDataCatalog Athena's built-in catalog (delete is rejected)
19# default the Scheduler schedule group, the RDS DB subnet
20# group, and friends — recreated by the emulator
21#
22# AWS.EC2.SecurityGroupRule is excluded because of a floci bug: deleting a
23# security group leaves its rules behind in DescribeSecurityGroupRules, and
24# those orphans can never be revoked (RevokeSecurityGroupIngress fails with
25# InvalidGroup.NotFound because the group is gone). They accumulate and make
26# every run report ~80 rules to delete that "succeed" and come straight back.
27# Deleting the group already removes the rules functionally; only the listing
28# is dirty. Reproduce with:
29# aws --endpoint-url http://localhost:4566 ec2 describe-security-group-rules
30#
31# floci's own internals are spared for the same convergence reason:
32# floci-* the emulator's internal buckets (Athena results, ...)
33# awslambda-us-east-1-tasks the emulator's Lambda task store
34bun alchemy unsafe nuke ./stacks/nuke.ts \
35 --local \
36 --include 'AWS.*' \
37 --exclude 'AWS.ApiGateway.Account' \
38 --exclude 'AWS.EC2.SecurityGroupRule' \
39 --concurrency 32 \
40 --timeout 60 \
41 --filter '["default", "AwsDataCatalog", "primary", "Default", "DefaultConfiguration"].includes(resource.LogicalId)' \
42 --filter 'resource.Type === "AWS.S3.Bucket" && (String(resource.bucketName).startsWith("floci-") || String(resource.bucketName) === "awslambda-us-east-1-tasks")' \
43 "$@"