Delete now defunct workspaces (#7322)

This commit is contained in:
Zachary Winnerman 2022-08-19 14:27:05 -04:00 committed by GitHub
parent b0e37accc9
commit 1d83b2610c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -55,6 +55,22 @@ func runTerraform(workspace string) error {
"-auto-approve",
"-no-color",
})
if err != nil {
return err
}
err := runCmd([]string{
"workspace",
"select",
"default",
})
if err != nil {
return err
}
err := runCmd([]string{
"workspace",
"delete",
workspace,
})
return err
}

View file

@ -82,6 +82,12 @@ for i in $((aws dynamodb scan --table-name sandbox-prod-lifecycle | jq -r '.Item
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
```
#### Cleanup untracked instances fully
This needs to be run in the deprovisioner terraform directory!
```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'; terraform workspace list | sed 's/ //g' | grep -v '.*default' | sed '/^$/d') | sort | uniq -u); do (terraform workspace select $i && terraform apply -destroy -auto-approve && terraform workspace select default && terraform workspace delete $i); [ $? = 0 ] || break; done
```
### Runbooks
#### 5xx errors
If you are seeing 5xx errors, find out what instance its from via the saved query here: https://us-east-2.console.aws.amazon.com/athena/home?region=us-east-2#/query-editor