Reputation: 24251
The Terraform provider I am using doesn't support import for at least one resource:
~/Downloads/terraform import module.fra.something.myid myid
module.fra.something.myid: Importing from ID "myid"...
Error: resource something doesn't support import
Yet, the documentation for Terraform doesn't even mention how such support could be added. So how to proceed?
Upvotes: 3
Views: 1271
Reputation: 24251
Look at the "Import" subsection of the documentation. It's in the different part of the document structure.
In short, you need to implement another function. On top of existing:
return &schema.Resource{
Create: resourceSomethingCreate,
Read: resourceSomethingRead,
Delete: resourceSomethingDelete,
Update: resourceSomethingUpdate,
Exists: resourceSomethingExists,
implement resourceSomethingImporter
:
Importer: resourceSomethingImporter,
And if your use-case is simple enough, you can re-use existing implementation by referring to:
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Upvotes: 2