It seems that the startup script doesn’t run right after creating and running the VM but only after resetting the machine. Could someone help me with it?
I too experienced this.
First thing to remember is that when running on a f1-micro instance it might take a while for the startup script to run. This is especially so if it has a lot to download and install.
Looking in the logs of my compute instance it appeared that the startup script was hanging for a long time when rebuilding the man-db pages. This can take an eternity on a small instance.
A pretty brutal way to speed this up is to edit the script so that it purges the man-db service just before you update the system.
apt-get remove -y --purge man-db apt-get -yq update apt-get -yq upgrade
This means that the instance wont have access to man pages, but it’s better than having the startup-script fail.
All in all, with the man-db service removed, it took 7 mins for the startup script to finish and copy the expected files over to the configured cloud bucket.