I have an application that is constantly creating/destroying virtual machine resources in AWS using Terraform. It works most of the time, but on occasion the Terraform destroy command fails to fully cleanup the AWS instance.
In this case, since I'm already using Terraform with success, I'd like to setup a CRON job that automatically discovers all the running AWS instances, determines if any of them failed to terminate properly, and then cleans up all the bad resources.
Rather than use a different tool I'd like to do this using Terraform. Is it possible to list all running VMs in AWS using Terraform if Terraform does not currently have any of them in the state file?
On a related note, I'd also like to keep this application as Cloud Agnostic as possible, so I don't want to rely on the AWS CLI if I can help it.