Fly machines automatically delete?

We’re building something that spins up a Fly Machine on every request, runs some process, and then shuts down the Fly Machine. We’re killing the process so the Machine stops automatically, but it doesn’t destroy itself (this is very convenient). However, we quickly hit our machine limit, since we don’t run any cleanup to destroy it. Is there a convenient way to do this automatically or do we need to run a separate cleanup task somewhere?


Are you asking if there’s a convenient way for a machine to auto-destroy itself after it exits?

If so, we recently added support for this in the machine config with the auto_destroy field (it’s a top-level field in the config). And there’s a pre-release version of the CLI adding a --rm flag to fly machine run to enable this behavior.


Fantastic, that’s exactly what I’m looking for. Let me try it out. Appreciate you!

It would be cool to document this field