From b2d94b1cc5e29d6c95a33662cecca63c4b52a0c3 Mon Sep 17 00:00:00 2001 From: Zachary Winnerman <98712682+zwinnerman-fleetdm@users.noreply.github.com> Date: Wed, 3 Aug 2022 19:01:45 -0400 Subject: [PATCH] Add some oneliners for cleaning up fleet sandbox (#7043) --- infrastructure/sandbox/readme.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/infrastructure/sandbox/readme.md b/infrastructure/sandbox/readme.md index f6a026eb9d..46c3765438 100644 --- a/infrastructure/sandbox/readme.md +++ b/infrastructure/sandbox/readme.md @@ -13,3 +13,19 @@ If you require changes beyond whats described here, contact @zwinnerman-fleetdm. 1. module.shared-infrastructure.kubernetes_manifest.targetgroupbinding is bugged sometimes, if it gives issues just comment it out 1. on a fresh apply, module.shared-infrastructure.aws_acm_certificate.main will have to be targeted first, then a normal apply can follow 1. If errors happen, see if applying again will fix it + +### Maintenance commands +#### Referesh fleet instances +```bash +for i in $(aws dynamodb scan --table-name sandbox-prod-lifecycle | jq -r '.Items[] | select(.State.S == "unclaimed") | .ID.S'); do helm uninstall $i; aws dynamodb delete-item --table-name sandbox-prod-lifecycle --key "{\"ID\": {\"S\": \"${i}\"}}"; done +``` + +#### Cleanup instances that are running, but not tracked +```bash +for i in $((aws dynamodb scan --table-name sandbox-prod-lifecycle | jq -r '.Items[] | .ID.S'; aws dynamodb scan --table-name sandbox-prod-lifecycle | jq -r '.Items[] | .ID.S'; helm list | tail -n +2 | cut -f 1) | sort | uniq -u); do helm uninstall $i; done +``` + +#### Cleanup instances that failed to provision +```bash +for i in $(aws dynamodb scan --table-name sandbox-prod-lifecycle | jq -r '.Items[] | select(.State.S == "provisioned") | .ID.S'); do helm uninstall $i; aws dynamodb delete-item --table-name sandbox-prod-lifecycle --key "{\"ID\": {\"S\": \"${i}\"}}"; done +```