cli: allow disabling "next steps" message in terraform plan #16059
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.
In #15884 we adjusted the plan output to give an explicit command to run to apply a plan, whereas before this command was just alluded to in the prose.
Since releasing that, we've got good feedback that it's confusing to include such direct instructions when Terraform is running in a workflow automation tool, because such tools usually abstract away exactly what commands are run and often require users to take different actions to proceed through the workflow.
To accommodate such environments while retaining helpful messages for normal CLI usage, here we introduce a new environment variable
TF_IN_AUTOMATION
which, when set to a non-empty value, is a hint to Terraform that it isn't being run in an interactive command shell and it should thus tone down this sort of "next steps" messaging.The documentation for this setting is included as part of the "...in automation" guide since it's not generally useful in other cases. We also intentionally disclaim comprehensive support for this since we want to avoid creating an extreme number of "if running in automation..." codepaths that would grow the testing matrix and hurt maintainability.
The focus is specifically on the output of the three commands we give in the automation guide, which at present means the following two situations:
terraform init
does not include the final paragraphs that suggest runningterraform plan
and tell you in what situations you might need to re-runterraform init
.terraform plan
does not include the final paragraphs that either warn about not specifying-out=...
or instruct to runterraform apply
with the generated plan file.