command/0.12checklist: Terraform 0.11 command to help prep for 0.12#21241
Merged
apparentlymart merged 4 commits intov0.11from May 8, 2019
Merged
command/0.12checklist: Terraform 0.11 command to help prep for 0.12#21241apparentlymart merged 4 commits intov0.11from
apparentlymart merged 4 commits intov0.11from
Conversation
This will grow to include various checks for steps we recommend users to take before upgrading to Terraform 0.12, including: - Upgrading providers to the minimum versions that support Terraform 0.12 - Warn about any names that violate the new stricter naming rules in 0.12, so users can optionally fix them before upgrading. - Upgrading any child modules that themselves have checklist warnings.
Terraform 0.11 had incomplete validation of resource and provider alias names, which worked only due to the strange way HIL parsed variable names. Terraform 0.12 (based on HIL) requires valid identifiers, so we'll let users know about this before they upgrade. It will be easier for users to deal with this while still on Terraform 0.11 because it won't run into parse errors trying to work with the invalid name.
We'll use the Terraform Registry API here (mimicking what the v0.12 plugin installer would do) to see if any of the provider versions already installed are 0.12-compatible, and produce a checklist item for any one that isn't. In the ideal case we can suggest an exact version to upgrade to -- the newest one with protocol 5 support -- but failing that we'll produce a less actionable error, potentially saying that the provider may see a new release soon if it seems like it's a HashiCorp-distributed provider (has a suitable entry in the registry) but nothing is compatible yet.
Along with the checklist items, we should also include some surrounding commentary to add context about what these recommendations are for. If no changes seem to be required at all, we direct the user back to the upgrade guide in case there are other steps described there that this tool is unable to detect or represent.
Contributor
Author
|
As with #21226, the CI tests will fail here because the v0.11 |
jbardin
approved these changes
May 8, 2019
|
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Please note that this PR is targeted at the
v0.11maintenance branch, not at themasterbranch.)There's a small set of tasks that are easier to do if handled before upgrading to Terraform 0.12, while still on 0.11:
terraform state mvcommand will accept these now-invalid names while the 0.12 version will not.terraform applyto rewrite all of the provider assignments in the state before upgrading, whereas 0.12 would consider it a syntax error.This tool can also serve a more short-lived purpose of providing a way to easily check if all of the providers used by a configuration have v0.12-compatible versions available.
The idea here is to merge this and include it in one last v0.11 release, and then the v0.12 upgrade guide would direct users to:
terraform initto make sure the working directory is in a consistent state.terraform applyto make sure the configuration, state, and remote objects are all consistent.terraform 0.12checklistto obtain a list of preparation steps, if any, or a prompt to refer back to the upgrade guide for next steps if everything looks okay.The main idea here is to leave the user in a state where all of the providers are already upgraded and the next step would be to upgrade to Terraform v0.12 and run
terraform 0.12upgradeto prepare the configuration.This extra v0.11 release should also include #21226, so upgrading to it will have benefit even if the checklist doesn't produce any tasks by avoiding imposing a strict dependency order on upgrades of different configurations in a decomposed environment that is using
terraform_remote_stateto connect between workspaces.Because this is a best-effort tool with a very temporary scope, I elected not to write any automated tests for this since the opportunity costs of doing so would be high relative to the value. Instead, I have tested this manually against a number of configurations, including both tailored configurations designed to trigger these checks and a number of module repositories index in the Terraform Registry that use complex module trees. If it turns out that there are bugs in this tool in practice, we'll use language in the 0.12 upgrade guide to warn about it and suggest workarounds.
The output of this tool is in GitHub-flavored Markdown format so it can easily be pasted into a Markdown-capable issue tracker, like GitHub issues. Here is an example of output from a tailored configuration I wrote to show off some of the different checklist item types: