Skip to content
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

cli: allow disabling "next steps" message in terraform plan #16059

Merged
merged 1 commit into from
Sep 14, 2017

Conversation

apparentlymart
Copy link
Contributor

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 running terraform plan and tell you in what situations you might need to re-run terraform init.
  • terraform plan does not include the final paragraphs that either warn about not specifying -out=... or instruct to run terraform apply with the generated plan file.

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 instructions when Terraform is running in a workflow
automation tool, because such tools usually abstract away exactly what
commands are run and 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 the "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 increase 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
  running "terraform plan" and tell you in what situations you might need
  to re-run "terraform init".
* "terraform plan" does not include the final paragraphs that either
  warn about not specifying "-out=..." or instruct to run
  "terraform apply" with the generated plan file.
Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the long run it might be cleaner to have another CLI implementation that handles the output appropriately, but I think that would require extending the CLI interface to change the "Output" method, or add another one to differentiate what is being shown.

I don't see any problem with this for now though.

@apparentlymart
Copy link
Contributor Author

Indeed I think with the limited focus this has for now (only on the commands we're documenting for use in automation) this less-invasive change is best, but in the long run we may want to diverge these changes more. At that point though we'd probably transition to machine-readable output for automation, once we're confident the system design is stable enough that we can maintain such an interface.

@apparentlymart apparentlymart merged commit 0fe43c8 into master Sep 14, 2017
@apparentlymart apparentlymart deleted the f-in-automation branch February 5, 2018 19:18
@ghost
Copy link

ghost commented Apr 5, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants