diff --git a/builder/googlecompute/step_create_instance.go b/builder/googlecompute/step_create_instance.go index 813295f30..1707ef654 100644 --- a/builder/googlecompute/step_create_instance.go +++ b/builder/googlecompute/step_create_instance.go @@ -69,13 +69,9 @@ func getImage(c *Config, d Driver) (*Image, error) { func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) d := state.Get("driver").(Driver) + sshPublicKey := state.Get("ssh_public_key").(string) ui := state.Get("ui").(packer.Ui) - sshPublicKey := "" - if sshPublicKeyRaw, ok := state.GetOk("ssh_public_key"); ok { - sshPublicKey = sshPublicKeyRaw.(string) - } - sourceImage, err := getImage(c, d) if err != nil { err := fmt.Errorf("Error getting source image for instance creation: %s", err) diff --git a/builder/googlecompute/step_create_ssh_key.go b/builder/googlecompute/step_create_ssh_key.go index 7d6c27622..1012867b6 100644 --- a/builder/googlecompute/step_create_ssh_key.go +++ b/builder/googlecompute/step_create_ssh_key.go @@ -37,6 +37,7 @@ func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { } state.Put("ssh_private_key", string(privateKeyBytes)) + state.Put("ssh_public_key", "") return multistep.ActionContinue }