title: How do I use terraform and AWS to run a script and then terminate or destroy the resources?
body: <p>I have a terraform script that, after <code>terraform apply</code>, successfully launches an AWS spot instance and then runs a bash script. After the script finishes running and the creation is complete, I have been manually destroying the spot instance with <code>terraform destroy</code>. This is inconvenient, because I either have to watch my email for a CloudWatch alert or periodically check-in on the progress of the script. Ideally, I would be able to automatically destroy the AWS resources I created automatically. Does anyone know how I should go about doing this? Am I using the wrong AWS resources, i.e. should I be using ECS?</p>