diff --git a/builtin/providers/digitalocean/import_digitalocean_ssh_key_test.go b/builtin/providers/digitalocean/import_digitalocean_ssh_key_test.go new file mode 100644 index 0000000000..05f55c5611 --- /dev/null +++ b/builtin/providers/digitalocean/import_digitalocean_ssh_key_test.go @@ -0,0 +1,28 @@ +package digitalocean + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccDigitalOceanSSHKey_importBasic(t *testing.T) { + resourceName := "digitalocean_ssh_key.foobar" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckDigitalOceanSSHKeyDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckDigitalOceanSSHKeyConfig_basic, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/builtin/providers/digitalocean/resource_digitalocean_ssh_key.go b/builtin/providers/digitalocean/resource_digitalocean_ssh_key.go index 094df96dd5..1495cb67de 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_ssh_key.go +++ b/builtin/providers/digitalocean/resource_digitalocean_ssh_key.go @@ -15,6 +15,9 @@ func resourceDigitalOceanSSHKey() *schema.Resource { Read: resourceDigitalOceanSSHKeyRead, Update: resourceDigitalOceanSSHKeyUpdate, Delete: resourceDigitalOceanSSHKeyDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "id": &schema.Schema{ @@ -84,6 +87,7 @@ func resourceDigitalOceanSSHKeyRead(d *schema.ResourceData, meta interface{}) er d.Set("name", key.Name) d.Set("fingerprint", key.Fingerprint) + d.Set("public_key", key.PublicKey) return nil }