One of the more interesting quirks of App Engine flexible environment is that App Engine launches Compute Engine virtual machines that you can’t spin down directly. The way to spin down App Engine flex is to delete all versions of the app. This will close down all of the VMs, and shut down your App Engine app.
You can do it manually through the web interface, you can do it manually by listing versions in gcloud then deleting them, or you can have a Makefile do it for you.
First I use the trick I wrote about capturing dynamic data from gcloud. Then I pipe that to a Makefile command that will delete the versions.
VERSIONLIST = $(shell gcloud app versions list --format='value[terminator=" "](version.id)') clean: gcloud app versions stop $(VERSIONLIST) -q
Note that I add -q to the command because I don’t want to be prompted; I just want them gone.