Ok. I tested deeper and forget the sleep 15
. It’s true for script, but not in this terraform & cloud build context.
The problem is tricky. With the verbosity debug, you can see this trace
DEBUG: Executing command: [u'/usr/bin/ssh', u'-T', u'-i', u'/builder/home/.ssh/google_compute_engine', u'-o', u'CheckHostIP=no', u'-o', u'HostKeyAlias=compute.7953677305751525032', u'-o', u'IdentitiesOnly=yes', u'-o', u'StrictHostKeyChecking=no', u'-o', u'UserKnownHostsFile=/builder/home/.ssh/google_compute_known_hosts', u'root@35.223.85.55', u'--', u'true']
Failed to add the host to the list of known hosts (/builder/home/.ssh/google_compute_known_hosts).
Permission denied (publickey).
Lot of boring things to read, I put in bold the problem: Cloud Build has no specific user and use root
to connect to the VM. For security reason, it’s not possible.
For solving this, set a dummy
(change this by what you want, except root) user in your scp
line
gcloud compute scp a.txt dummy@deleteme-vm6:/tmp ...
Tell me if it’s OK now.
PS: Your tf
file and your cloudbuild.yaml
file are desynchronized in the vm name.