diff --git a/builtin/providers/triton/resource_key.go b/builtin/providers/triton/resource_key.go index b941cb0bf..dc8d16327 100644 --- a/builtin/providers/triton/resource_key.go +++ b/builtin/providers/triton/resource_key.go @@ -20,6 +20,9 @@ func resourceKey() *schema.Resource { Exists: resourceKeyExists, Read: resourceKeyRead, Delete: resourceKeyDelete, + Importer: &schema.ResourceImporter{ + State: resourceKeyImporter, + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -87,7 +90,7 @@ func resourceKeyExists(d *schema.ResourceData, meta interface{}) (bool, error) { func resourceKeyRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*cloudapi.Client) - key, err := client.GetKey(d.Get("name").(string)) + key, err := client.GetKey(d.Id()) if err != nil { return err } @@ -108,3 +111,7 @@ func resourceKeyDelete(d *schema.ResourceData, meta interface{}) error { return nil } + +func resourceKeyImporter(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + return []*schema.ResourceData{d}, nil +}