hashicorp/terraform-plugin-docs

[Question] Why do we have to provide the `--tf-version` to the `generate` command?

andreaangiolillo opened this issue · 2 comments

I'd like to understand the impact of using an older version of Terraform for the generate command. It would be great if you could update your README to clarify this matter. Thanks!

Hey there @andreaangiolillo 👋🏻 , the --tf-version is not required and if not provided will either:

  • Use the Terraform binary found in your environment (i.e.PATH env var)
  • Download the latest Terraform binary from releases.hashicorp.com

The terraform binary is used to run the two commands terraform init and then terraform providers schema, which the latter command provides the schema information that we build the markdown documentation with.

So the general answer to your question is that only changes to the JSON output of the command terraform providers schema will affect the documentation generator. We typically only make backwards-compatible changes to the provider schema, so using earlier versions of Terraform (needs to be at least 0.12) will likely be fine. I'd recommend using the latest version of Terraform that your provider supports (which hopefully, should just be the latest version of Terraform).

An example of an upcoming change that will require later versions of Terraform would be generating docs for the upcoming provider defined functions, which the function schemas will only be available via the terraform providers schema command in Terraform v1.8.x and later.

I will add this information to our README.md and the --help text for the --tf-version flag. Thanks!