website: Update the CLI commands index page for latest help output

My initial motivation here was to update the example output from
Terraform's top-level help list to match recent updates in the layout
and language used.

However, while here I took the opportunity to update some dated language
that was not consistent with our modern documentation writing style,
in particular including a totally unnecessary and potentially-alienating
claim that Terraform is "very easy to use". Our modern writing style
discourages this sort of "boastful" language and encourages us to focus on
the facts at hand.
This commit is contained in:
Martin Atkins 2020-10-23 17:17:59 -07:00
parent 248cf7f13a
commit 6a44586a8f
2 changed files with 52 additions and 59 deletions

View File

@ -105,7 +105,7 @@ func initCommands(
// The command list is included in the terraform -help
// output, which is in turn included in the docs at
// website/source/docs/commands/index.html.markdown; if you
// website/docs/commands/index.html.markdown; if you
// add, remove or reclassify commands then consider updating
// that to match.

View File

@ -3,86 +3,79 @@ layout: "docs"
page_title: "Commands"
sidebar_current: "docs-commands"
description: |-
Terraform is controlled via a very easy to use command-line interface (CLI). Terraform is only a single command-line application: terraform. This application then takes a subcommand such as "apply" or "plan". The complete list of subcommands is in the navigation to the left.
Main usage information for the Terraform CLI tool.
---
# Terraform Commands (CLI)
> **Hands-on:** Try the [Terraform: Get Started](https://learn.hashicorp.com/collections/terraform/aws-get-started?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) collection on HashiCorp Learn.
Terraform is controlled via a very easy to use command-line interface (CLI).
Terraform is only a single command-line application: terraform. This application
then takes a subcommand such as "apply" or "plan". The complete list of subcommands
is in the navigation to the left.
The command line interface to Terraform is via the `terraform` command, which
accepts a variety of subcommands such as `terraform init` or `terraform plan`.
A full list of all of the supported subcommands is in the navigation section
of this page.
The terraform CLI is a well-behaved command line application. In erroneous cases,
a non-zero exit status will be returned. It also responds to -h and --help as you'd
most likely expect.
We refer to the `terraform` command line tool as "Terraform CLI" elsewhere
in the documentation. This terminology is often used to distinguish it from
other components you might use in the Terraform product family, such as
[Terraform Cloud](/docs/cloud/) or
the various [Terraform providers](/docs/providers/), which are developed and
released separately from Terraform CLI.
To view a list of the available commands at any time, just run terraform with no arguments:
To view a list of the commands available in your current Terraform version,
run `terraform` with no additional arguments:
```text
Usage: terraform [global options] <subcommand> [args]
The available commands for execution are listed below.
The most common, useful commands are shown first, followed by
less common or more advanced commands. If you're just getting
started with Terraform, stick with the common commands. For the
other commands, please read the help and docs before usage.
The primary workflow commands are given first, followed by
less common or more advanced commands.
Common commands:
apply Builds or changes infrastructure
console Interactive console for Terraform interpolations
destroy Destroy Terraform-managed infrastructure
env Workspace management
fmt Rewrites config files to canonical format
get Download and install modules for the configuration
graph Create a visual graph of Terraform resources
import Import existing infrastructure into Terraform
init Initialize a Terraform working directory
login Obtain and save credentials for a remote host
logout Remove locally-stored credentials for a remote host
output Read an output from a state file
plan Generate and show an execution plan
providers Prints a tree of the providers used in the configuration
refresh Update local state file against real resources
show Inspect Terraform state or plan
taint Manually mark a resource for recreation
untaint Manually unmark a resource as tainted
validate Validates the Terraform files
version Prints the Terraform version
workspace Workspace management
Main commands:
init Prepare your working directory for other commands
validate Check whether the configuration is valid
plan Show changes required by the current configuration
apply Create or update infrastructure
destroy Destroy previously-created infrastructure
All other commands:
debug Debug output management (experimental)
force-unlock Manually unlock the terraform state
state Advanced state management
console Try Terraform expressions at an interactive command prompt
fmt Reformat your configuration in the standard style
force-unlock Release a stuck lock on the current workspace
get Install or upgrade remote Terraform modules
graph Generate a Graphviz graph of the steps in an operation
import Associate existing infrastructure with a Terraform resource
login Obtain and save credentials for a remote host
logout Remove locally-stored credentials for a remote host
output Show output values from your root module
providers Show the providers required for this configuration
refresh Update the state to match remote systems
show Show the current state or a saved plan
state Advanced state management
taint Mark a resource instance as not fully functional
untaint Remove the 'tainted' state from a resource instance
version Show the current Terraform version
workspace Workspace management
Global options (use these before the subcommand, if any):
-chdir=DIR Switch to a different working directory before executing
the given subcommand.
-help Show this help output, or the help for a specified
subcommand.
-version An alias for the "version" subcommand.
-chdir=DIR Switch to a different working directory before executing the
given subcommand.
-help Show this help output, or the help for a specified subcommand.
-version An alias for the "version" subcommand.
```
To get help for any specific command, use the -help option to the relevant
subcommand. For example, to see help about the graph subcommand:
(The output from your current Terraform version may be different than the
above example.)
```text
$ terraform graph -help
Usage: terraform graph [options] PATH
To get specific help for any specific command, use the `-help` option with the
relevant subcommand. For example, to see help about the "validate" subcommand
you can run `terraform validate -help`.
Outputs the visual graph of Terraform resources. If the path given is
the path to a configuration, the dependency graph of the resources are
shown. If the path is a plan file, then the dependency graph of the
plan itself is shown.
The graph is outputted in DOT format. The typical program that can
read this format is GraphViz, but many web services are also available
to read this format.
```
The inline help built in to Terraform CLI describes the most important
characteristics of each command. For more detailed information, refer to each
command's section of this documentation, available in the navigation
section of this page.
## Switching working directory with `-chdir`