Skip to content

Commit a16b24a

Browse files
author
JT
committed
Merge branch 'master' of github.com:hashicorp/terraform
2 parents 07ab6dd + 0da10b8 commit a16b24a

7 files changed

Lines changed: 185 additions & 1 deletion

File tree

terraform/graph_dot.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/hashicorp/terraform/depgraph"
8+
"github.com/hashicorp/terraform/digraph"
89
)
910

1011
// GraphDot returns the dot formatting of a visual representation of
@@ -141,6 +142,49 @@ func graphDotAddResources(buf *bytes.Buffer, g *depgraph.Graph) {
141142
buf.WriteString(edgeBuf.String())
142143
buf.WriteString("\n")
143144
}
145+
146+
// Handle the meta resources
147+
edgeBuf.Reset()
148+
for _, n := range g.Nouns {
149+
_, ok := n.Meta.(*GraphNodeResourceMeta)
150+
if !ok {
151+
continue
152+
}
153+
154+
// Determine which edges to add
155+
var edges []digraph.Edge
156+
if hasDiff {
157+
for _, e := range n.Edges() {
158+
rn, ok := e.Tail().(*depgraph.Noun).Meta.(*GraphNodeResource)
159+
if !ok {
160+
continue
161+
}
162+
if rn.Resource.Diff == nil || rn.Resource.Diff.Empty() {
163+
continue
164+
}
165+
edges = append(edges, e)
166+
}
167+
} else {
168+
edges = n.Edges()
169+
}
170+
171+
// Do not draw if we have no edges
172+
if len(edges) == 0 {
173+
continue
174+
}
175+
176+
for _, e := range edges {
177+
target := e.Tail()
178+
edgeBuf.WriteString(fmt.Sprintf(
179+
"\t\"%s\" -> \"%s\";\n",
180+
n,
181+
target))
182+
}
183+
}
184+
if edgeBuf.Len() > 0 {
185+
buf.WriteString(edgeBuf.String())
186+
buf.WriteString("\n")
187+
}
144188
}
145189

146190
func graphDotAddResourceProviders(buf *bytes.Buffer, g *depgraph.Graph) {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: "docs"
3+
page_title: "Command: apply"
4+
sidebar_current: "docs-commands-apply"
5+
---
6+
7+
# Command: apply
8+
9+
The `terraform apply` command is used to apply the changes required
10+
to reach the desired state of the configuration, or the pre-determined
11+
set of actions generated by a `terraform plan` execution plan.
12+
13+
## Usage
14+
15+
Usage: `terraform apply [options] [dir]`
16+
17+
By default, `apply` scans the current directory for the configuration
18+
and applies the changes appropriately. However, a path to another configuration
19+
or an execution plan can be provided. Execution plans can be used to only
20+
execute a pre-determined set of actions.
21+
22+
The command-line flags are all optional. The list of available flags are:
23+
24+
* `-no-color` - Disables output with coloring.
25+
26+
* `-state=path` - Path to the state file. Defaults to "terraform.tfstate".
27+
28+
* `-state-out=path` - Path to write updated state file. By default, the
29+
`-state` path will be used.
30+
31+
* `-var 'foo=bar'` - Set a variable in the Terraform configuration. This
32+
flag can be set multiple times.
33+
34+
* `-var-file=foo` - Set variables in the Terraform configuration from
35+
a file. If "terraform.tfvars" is present, it will be automatically
36+
loaded if this flag is not specified.
37+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
layout: "docs"
3+
page_title: "Command: graph"
4+
sidebar_current: "docs-commands-graph"
5+
---
6+
7+
# Command: graph
8+
9+
The `terraform graph` command is used to generate a visual
10+
representation of either a configuration or execution plan.
11+
The output is in the DOT format, which can be used by
12+
GraphViz to generate charts.
13+
14+
15+
## Usage
16+
17+
Usage: `terraform output [options] [input]`
18+
19+
By default, `output` scans the current directory for the configuration
20+
and generates the output for that configuration. However, a path to
21+
another configuration or an execution plan can be provided. Execution plans
22+
provide more details on creation, deletion or changes.
23+
24+
## Generating Images
25+
26+
The output of `terraform graph` is in the DOT format, which can
27+
easily be converted to an image by making use of `dot` provided
28+
by GraphViz:
29+
30+
```
31+
$ terraform graph | dot -Tpng > graph.png
32+
```
33+
34+
Alternatively, the webbased [GraphViz Workspace](http://graphviz-dev.appspot.com)
35+
can be used to quickly render DOT file inputs as well.
36+
37+
Here is an example graph output:
38+
![Graph Example](/images/graph-example.png)
39+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
layout: "docs"
3+
page_title: "Command: output"
4+
sidebar_current: "docs-commands-output"
5+
---
6+
7+
# Command: output
8+
9+
The `terraform output` command is used to extract the value of
10+
an output variable from the state file.
11+
12+
## Usage
13+
14+
Usage: `terraform output [options] NAME`
15+
16+
By default, `plan` requires only a variable name and looks in the
17+
current directory for the state file to query.
18+
19+
The command-line flags are all optional. The list of available flags are:
20+
21+
* `-state=path` - Path to the state file. Defaults to "terraform.tfstate".
22+
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: plan"
4+
sidebar_current: "docs-commands-plan"
5+
---
6+
7+
# Command: plan
8+
9+
The `terraform plan` command is used to create an execution plan. Terraform
10+
performs a refresh, unless explicitly disabled, and then determines what
11+
actions are necessary to achieve the desired state specified in the
12+
configuration files. The plan can be saved using `-out`, and then provided
13+
to `terraform apply` to ensure only the pre-planned actions are executed.
14+
15+
## Usage
16+
17+
Usage: `terraform plan [options] [dir]`
18+
19+
By default, `plan` requires no flags and looks in the current directory
20+
for the configuration and state file to refresh.
21+
22+
The command-line flags are all optional. The list of available flags are:
23+
24+
* `-destroy` - If set, generates a plan to destroy all the known resources.
25+
26+
* `-no-color` - Disables output with coloring.
27+
28+
* `-out=path` - The path to save the generated execution plan.
29+
30+
* `-refresh=true` - Update the state prior to checking for differences.
31+
32+
* `-state=path` - Path to the state file. Defaults to "terraform.tfstate".
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+

website/source/docs/providers/aws/r/instance.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ The following arguments are supported:
2727
* `availability_zone` - (Optional) The AZ to start the instance in.
2828
* `instance_type` - (Required) The type of instance to start
2929
* `key_name` - (Optional) The key name to use for the instance.
30-
* `security_groups` - (Optional) A list of security group IDs to associate with.
30+
* `security_groups` - (Optional) A list of security group IDs or names to associate with.
31+
If you are within a VPC, you'll need to use the security group ID. Otherwise,
32+
for EC2, use the security group name.
3133
* `subnet_id` - (Optional) The VPC Subnet ID to launch in.
3234
* `source_dest_check` - (Optional) Controls if traffic is routed to the instance when
3335
the destination address does not match the instance. Used for NAT or VPNs. Defaults false.
50.8 KB
Loading

0 commit comments

Comments
 (0)