Skip to content

Commit 1a94a23

Browse files
committed
website: documenting the CLI
1 parent 3808775 commit 1a94a23

5 files changed

Lines changed: 129 additions & 39 deletions

File tree

website/source/docs/commands/agent.html.markdown

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
layout: "docs"
3+
page_title: "Commands"
4+
sidebar_current: "docs-commands"
5+
---
6+
7+
# Terraform Commands (CLI)
8+
9+
Terraform is controlled via a very easy to use command-line interface (CLI).
10+
Terraform is only a single command-line application: terraform. This application
11+
then takes a subcommand such as "apply" or "plan". The complete list of subcommands
12+
is in the navigation to the left.
13+
14+
The terraform CLI is a well-behaved command line application. In erroneous cases,
15+
a non-zero exit status will be returned. It also responds to -h and --help as you'd
16+
most likely expect.
17+
18+
To view a list of the available commands at any time, just run terraform with no arguments:
19+
20+
```
21+
$ terraform
22+
usage: terraform [--version] [--help] <command> [<args>]
23+
24+
Available commands are:
25+
apply Builds or changes infrastructure
26+
graph Create a visual graph of Terraform resources
27+
output Read an output from a state file
28+
plan Generate and show an execution plan
29+
refresh Update local state file against real resources
30+
show Inspect Terraform state or plan
31+
version Prints the Terraform version
32+
```
33+
34+
To get help for any specific command, pass the -h flag to the relevant subcommand. For example,
35+
to see help about the members subcommand:
36+
37+
```
38+
$ terraform graph -h
39+
Usage: terraform graph [options] PATH
40+
41+
Outputs the visual graph of Terraform resources. If the path given is
42+
the path to a configuration, the dependency graph of the resources are
43+
shown. If the path is a plan file, then the dependency graph of the
44+
plan itself is shown.
45+
46+
The graph is outputted in DOT format. The typical program that can
47+
read this format is GraphViz, but many web services are also available
48+
to read this format.
49+
```
50+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
layout: "docs"
3+
page_title: "Command: refresh"
4+
sidebar_current: "docs-commands-refresh"
5+
---
6+
7+
# Command: refresh
8+
9+
The `terraform refresh` command is used to reconcile the state Terraform
10+
knows about (via it's state file) with the real-world infrastructure.
11+
The can be used to detect any drift from the last-known state, and to
12+
update the state file.
13+
14+
This does not modify infrastructure, but does modify the state file.
15+
If the state is changed, this may cause changes to occur during the next
16+
plan or apply.
17+
18+
## Usage
19+
20+
Usage: `terraform refresh [options] [dir]`
21+
22+
By default, `refresh` requires no flags and looks in the current directory
23+
for the configuration and state file to refresh.
24+
25+
The command-line flags are all optional. The list of available flags are:
26+
27+
* `-no-color` - Disables output with coloring
28+
29+
* `-state=path` - Path to read and write the state file to. Defaults to "terraform.tfstate".
30+
31+
* `-state-out=path` - Path to write updated state file. By default, the
32+
`-state` path will be used.
33+
34+
* `-var 'foo=bar'` - Set a variable in the Terraform configuration. This
35+
flag can be set multiple times.
36+
37+
* `-var-file=foo` - Set variables in the Terraform configuration from
38+
a file. If "terraform.tfvars" is present, it will be automatically
39+
loaded if this flag is not specified.
40+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
layout: "docs"
3+
page_title: "Command: show"
4+
sidebar_current: "docs-commands-show"
5+
---
6+
7+
# Command: show
8+
9+
The `terraform show` command is used to provide human-readable output
10+
from a state or plan file. This can be used to inspect a plan to ensure
11+
that the planned operations are expected, or to inspect the current state
12+
as terraform sees it.
13+
14+
## Usage
15+
16+
Usage: `terraform show [options] <path>`
17+
18+
You must call `show` with a path to either a Terraform state file or plan
19+
file.
20+
21+
The command-line flags are all optional. The list of available flags are:
22+
23+
* `-no-color` - Disables output with coloring
24+

website/source/layouts/docs.erb

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,29 @@
1515
<li<%= sidebar_current("docs-commands") %>>
1616
<a href="/docs/commands/index.html">Commands (CLI)</a>
1717
<ul class="nav">
18-
<li<%= sidebar_current("docs-commands-agent") %>>
19-
<a href="/docs/commands/agent.html">agent</a>
20-
</li>
21-
22-
<li<%= sidebar_current("docs-commands-forceleave") %>>
23-
<a href="/docs/commands/force-leave.html">force-leave</a>
24-
</li>
18+
<li<%= sidebar_current("docs-commands-apply") %>>
19+
<a href="/docs/commands/apply.html">apply</a>
20+
</li>
2521

26-
<li<%= sidebar_current("docs-commands-join") %>>
27-
<a href="/docs/commands/join.html">join</a>
28-
</li>
22+
<li<%= sidebar_current("docs-commands-graph") %>>
23+
<a href="/docs/commands/graph.html">graph</a>
24+
</li>
2925

30-
<li<%= sidebar_current("docs-commands-keygen") %>>
31-
<a href="/docs/commands/keygen.html">keygen</a>
26+
<li<%= sidebar_current("docs-commands-output") %>>
27+
<a href="/docs/commands/output.html">output</a>
3228
</li>
3329

34-
<li<%= sidebar_current("docs-commands-leave") %>>
35-
<a href="/docs/commands/leave.html">leave</a>
36-
</li>
30+
<li<%= sidebar_current("docs-commands-plan") %>>
31+
<a href="/docs/commands/plan.html">plan</a>
32+
</li>
3733

38-
<li<%= sidebar_current("docs-commands-members") %>>
39-
<a href="/docs/commands/members.html">members</a>
34+
<li<%= sidebar_current("docs-commands-refresh") %>>
35+
<a href="/docs/commands/refresh.html">refresh</a>
4036
</li>
4137

42-
<li<%= sidebar_current("docs-commands-monitor") %>>
43-
<a href="/docs/commands/monitor.html">monitor</a>
38+
<li<%= sidebar_current("docs-commands-show") %>>
39+
<a href="/docs/commands/show.html">show</a>
4440
</li>
45-
46-
<li<%= sidebar_current("docs-commands-info") %>>
47-
<a href="/docs/commands/info.html">info</a>
48-
</li>
4941
</ul>
5042
</li>
5143

0 commit comments

Comments
 (0)