From 7594c09623476afd369562609697e9f1f7a3334f Mon Sep 17 00:00:00 2001 From: Antoine Grondin Date: Sun, 25 Oct 2015 16:29:01 -0400 Subject: [PATCH] provider/digitalocean: fix issue #3628 by accepting SSH fingerprints --- .../digitalocean/resource_digitalocean_droplet.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/builtin/providers/digitalocean/resource_digitalocean_droplet.go b/builtin/providers/digitalocean/resource_digitalocean_droplet.go index 49feba1c9bf4..4dbb77ab73d6 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_droplet.go +++ b/builtin/providers/digitalocean/resource_digitalocean_droplet.go @@ -140,14 +140,17 @@ func resourceDigitalOceanDropletCreate(d *schema.ResourceData, meta interface{}) opts.SSHKeys = make([]godo.DropletCreateSSHKey, 0, sshKeys) for i := 0; i < sshKeys; i++ { key := fmt.Sprintf("ssh_keys.%d", i) - id, err := strconv.Atoi(d.Get(key).(string)) - if err != nil { - return err + sshKeyRef := d.Get(key).(string) + + var sshKey godo.DropletCreateSSHKey + // sshKeyRef can be either an ID or a fingerprint + if id, err := strconv.Atoi(sshKeyRef); err == nil { + sshKey.ID = id + } else { + sshKey.Fingerprint = sshKeyRef } - opts.SSHKeys = append(opts.SSHKeys, godo.DropletCreateSSHKey{ - ID: id, - }) + opts.SSHKeys = append(opts.SSHKeys, sshKey) } }