diff --git a/builder/hcloud/step_create_server.go b/builder/hcloud/step_create_server.go index 89c80d88f..ffaa6a60e 100644 --- a/builder/hcloud/step_create_server.go +++ b/builder/hcloud/step_create_server.go @@ -43,6 +43,10 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu state.Put("error", fmt.Errorf("Error fetching SSH key: %s", err)) return multistep.ActionHalt } + if sshKey == nil { + state.Put("error", fmt.Errorf("Could not find key: %s", k)) + return multistep.ActionHalt + } sshKeys = append(sshKeys, sshKey) }