-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Terraform 0.12.x configuration #113
Conversation
Hi @moatra, and thanks for your interest in this project! We know that support for Terraform 0.12 is important... and that it's a beast. Although I value your proposal, we can't simply throw away existing functionality from I'll have a look at your implementation soon. Please understand though, that this migration has to be done carefully and feature complete and will have to be guided by more senior contributors. |
Hey @metmajer! I completely understand; this PR is an experiment with using the terraform-config-inspect module to get 80% of the functionality for 20% of the work (and a project for me to learn go). I realize a lot of the changes in the PR are pretty aggressive, and if there's any future for the PR I'm happy to dial it back. I strongly doubt terraform-config-inspect will be willing to sniff comments, so if 100% feature support is mandatory, the approach in this PR won't work. That said, my gut says that there's probably a good chunk of the terraform-docs user base that needs 0.12 support but not comment sniffing support. If so, is there a path forward with a transient release using terraform-config-inspect while the dev work for the correct solution is ongoing? |
My .02 is that I'd love a version which works with .12. Frankly terraform-docs w/o .12 support is an antiquated tool which makes me sad. I've already converted a very large TF codebase to .12 and I'm sure I'm not alone. Halp. :) |
Just to throw some additional weight behind this; I have somewhere around 200k lines of HCL that have been converted to HCL2 and previously relied upon As I understand it, we are waiting on hashicorp/terraform-config-inspect#17 and hashicorp/terraform-config-inspect#18 -- is there any outstanding work we have to do outside of that to help support pushing an update that works with HCL2? |
@sudoforge You may want to look at #62 for the current status. We're waiting for hashicorp/terraform-config-inspect contributors to elaborate on our feature and pull requests. You want to help? Here are a couple of suggestions:
|
@metmajer Woah, hey, it sounds like I may have misworded my earlier comment or that you may be misconstruing it; I was legitimately asking what was still outstanding so that I could help out (either via code or other means). From one FOSS maintainer to another, many apologies. I'll bug Hashicorp, and take a look at resolving the conflicts in this PR. |
Here's a summary of where things stand today for generating Terraform 0.12 module docs:
|
You could use |
@jstewmon How would this be more helpful as opposed to using this PR? terraform-config-inspect lacks features that we depend on to remain backwards compatible. |
@metmajer I was just offering a suggestion in direct response to this line in @moatra's comment:
|
Hi! I am interested in contributing towards this PR. Are the primary blockers for this PR the lack of pulling description from comments and the lack of the terraform-config-inspect exposes line numbers which should make it possible to implement |
should we keep 0.12 support behind a flag so that we do not break existing workflows? |
@moatra I just created branch Or alternatively you can enable |
I'm in the middle of rebasing this PR and resolving the conflicts. I want to propose these changes while doing so:
What I have in mind is to continue with the rebase and resolve all the conflicts and on the consecutive commits here apply the above changes I mentioned and finally proceed with this PR. @moatra I'd love your feedback on this, and also from all the other folks here. /cc @metmajer |
@khos2ow I agree with the changes you have proposed; keeping PRs as small and focused as possible is a great goal. |
I'm done with rebasing and fixing the issues. I've used the binary of this PR on some real world config of my own and some from opensource community, and the amount of different is minimal and acceptable. Although I suspect that's gonna grow because we're going to add I'm gonna merge this PR now and continue on the points I mentioned earlier on consecutive PRs. Thank you so much @moarta for the awesome initiative you took with the PR ❤️ 💯 |
Thanks @khos2ow for taking the lead on this one and making it happen! |
BREAKING CHANGE: - We've decided to rename `input` to `variable` which is a known terminology in Terraform configuration. The affected parts are: 1) markdown titles have been changed to `## Variables` 2) json item has been renamed to `variables`. - Also flag `--sort-inputs-by-required` has been deprecated in favor of `--sort-by-required`. The depracted flag will be completely removed in the second release from now. Originally-Authored-By: Thomas Alton <thomas.alton@gmail.com> Original-Pull-Request: #113
BREAKING CHANGE: - We've decided to rename `input` to `variable` which is a known terminology in Terraform configuration. The affected parts are: 1) markdown titles have been changed to `## Variables` 2) json item has been renamed to `variables`. - Also flag `--sort-inputs-by-required` has been deprecated in favor of `--sort-by-required`. The depracted flag will be completely removed in the second release from now. Originally-Authored-By: Thomas Alton <thomas.alton@gmail.com> Original-Pull-Request: #113
… a Docker image for `terraform-docs` The new GCP Terraform module manages a Google Cloud bastion, using Google DNS for the bastion host record, Stackdriver for logs, and Google Cloud Storage for SSH hostkeys and optional `additional external users`. The AWS bastion module is moved to its own `aws` sub-directory - the next release of the AWS module will require users to update their `source` argument to include the `//aws` path and a module-specific release tag such as `aws-vx.y.z`. A Docker image is used to incorparate `terraform-docs` output into per-module ReadMe files, until a version of terraform-docs is released that natively supports Terraform 0.12. * Terraform-docs pull request: terraform-docs/terraform-docs#113 * Docker image and Terraform 0.12 workaround: cytopia/docker-terraform-docs#8
… a Docker image for `terraform-docs` The new GCP Terraform module manages a Google Cloud bastion, using Google DNS for the bastion host record, Stackdriver for logs, and Google Cloud Storage for SSH hostkeys and optional `additional external users`. The AWS bastion module is moved to its own `aws` sub-directory - the next release of the AWS module will require users to update their `source` argument to include the `//aws` path and a module-specific release tag such as `aws-vx.y.z`. A Docker image is used to incorparate `terraform-docs` output into per-module ReadMe files, until a version of terraform-docs is released that natively supports Terraform 0.12. * Terraform-docs pull request: terraform-docs/terraform-docs#113 * Docker image and Terraform 0.12 workaround: cytopia/docker-terraform-docs#8
@khos2ow I'm excited to see this merged, what was the plan for tagging a release? |
Originally-Authored-By: Thomas Alton <thomas.alton@gmail.com> Original-Pull-Request: terraform-docs#113
@kmfk I just came back from holiday break, I'm targeting to cut a RC release sometime next week. |
Originally-Authored-By: Thomas Alton <thomas.alton@gmail.com> Original-Pull-Request: terraform-docs#113
* Show 'providers' information * Fix for unsorted providers list BREAKING CHANGE: - With Terraform 0.12 the information about `providers` being used in the module will be generated by default. This will cause the first generation of documents with the latest release of `terraform-docs` binary be slightly different than before, now there will be `Providers` section in Markdown and `providers` block in JSON. You can ignore this by using new `--no-providers` flag if you choose to. Originally-Authored-By: Thomas Alton <thomas.alton@gmail.com> Original-Pull-Request: #113
… a Docker image for `terraform-docs` (#22) * Add a GCP bastion module, move the AWS module to a sub-directory, use a Docker image for `terraform-docs` The new GCP Terraform module manages a Google Cloud bastion, using Google DNS for the bastion host record, Stackdriver for logs, and Google Cloud Storage for SSH hostkeys and optional `additional external users`. The AWS bastion module is moved to its own `aws` sub-directory - the next release of the AWS module will require users to update their `source` argument to include the `//aws` path and a module-specific release tag such as `aws-vx.y.z`. A Docker image is used to incorparate `terraform-docs` output into per-module ReadMe files, until a version of terraform-docs is released that natively supports Terraform 0.12. * Terraform-docs pull request: terraform-docs/terraform-docs#113 * Docker image and Terraform 0.12 workaround: cytopia/docker-terraform-docs#8 * Update GCP firewall rule to be optional, use the bastion name for the FW rule tag The GCP firewall rule is optionally created, if the `ssh_cidr_blocks` input is set to an empty list. The GCP instance template and firewall rule use the bastion name as the tag that associates the firewall rule with the bastion compute instance. * Update GCP module providers to be inline with other related 3rd party modules * GCP module additional external users GCS object is optional, other fixes The additional external users script is only written to GCS if the `additional_external_users` input is defined. References to `user data` were renamed to `setup script` in template resources. The Google provider version is further relaxed to 2.X. * Update the GCP `ssh_public_key_file` input to behave like the AWS module The `ssh_public_key_file` input was initially given an unfortunate name, and actually reflects the content (not the file name) of an SSH public key. For now, the GCP module will match the AWS one.
This PR is meant as a proposal for adding Terraform 0.12 support. It replaces the current AST parsing with the hashicorp/terraform-config-inspect module.
(I picked up golang this weekend to make this change, so I apologize in advance for anything non-idiomatic. Feedback appreciated!)
Major changes:
--no-sort
flag, as the terraform-config-inspect module doesn't seem to return blocks in source order--with-aggregate-type-defaults
flag. All output fordefault
is now json.--providers
flag to include information on the provider configuration needed by the module.vendor/
directorypath
cli input from multiple directories or files to just one directory; (tfconfig.LoadModule()
only supports loading one directory)I updated
master
on the fork repo to directly supportgo get github.com/moatra/terraform-docs
if you'd like to try it out locally.Thoughts? Concerns? Changes?
(ref: #62 )