Googlecompute windows - Password expiry

I use googlecompute to create a Windows image. I use winrm as communicator. The password is autogenerated by Packer and I can successfully connect to WinRM during the build of the image. However, I have the feeling that the password expires after 20 minutes, because I get the following error during my build process:

InvalidCredentialsError: the specified credentials were rejected by the server

And this is happening exactly after 20 minutes. I’ve seen this multiple times now.

I’ve checked the source of packer and found that an expiry is set. But to my understanding this is set to 5 minutes?

See: packer/step_create_windows_password.go at master · hashicorp/packer · GitHub

ExpireOn: time.Now().Add(time.Minute * 5)
  • Does the auto generated Windows password expire after 20 minutes?
  • Is it possible to extend that expiry?