Skip to content

Proposal Documentation: Add import block example to resource docs

The AWS Provider resource documentation always contains an import code example using a terraform import block. Since using a block is imho in nearly all cases the better option compared to using the CLI I would propose adding such an example in the import section of the resource documentation.
Does anyone else have opinions about this, or is there a good reason not to add such an example to individual resources?

Implementation

While the aws provider does not use terraform-plugin-docs it would be possible to create a generic resource template for it, which only adds a import block example like this:

In Terraform v1.5.0 and later, use an import block to import {{.Name}}. For example:

import {
  to = {{ .Name }}.example
  id = "see CLI command below for ID"
}

below would be the CLI command to import, with info about the resource ID.
Having the ID filled with a resource specific example would of course be better, but would require having a very similar template file for each resource, with only this section containing "handwritten" infos about the ID