After playing around with GCP's Ubuntu VM, I disconnected with UFW enabled => rebooted and couldn't connect to ssh.
Write a startup script that disables
UFW as custom metadata in the VM instance information.
Then restart the VM instance.
#! /bin/bash /usr/sbin/ufw disable
↓ Like this. It is recognized as a startup script by using
startup-script as a key.