Merge branch 'master' of github.com:hashicorp/terraform
This commit is contained in:
commit
a16b24ab4a
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform/depgraph"
|
||||
"github.com/hashicorp/terraform/digraph"
|
||||
)
|
||||
|
||||
// GraphDot returns the dot formatting of a visual representation of
|
||||
|
@ -141,6 +142,49 @@ func graphDotAddResources(buf *bytes.Buffer, g *depgraph.Graph) {
|
|||
buf.WriteString(edgeBuf.String())
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
|
||||
// Handle the meta resources
|
||||
edgeBuf.Reset()
|
||||
for _, n := range g.Nouns {
|
||||
_, ok := n.Meta.(*GraphNodeResourceMeta)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// Determine which edges to add
|
||||
var edges []digraph.Edge
|
||||
if hasDiff {
|
||||
for _, e := range n.Edges() {
|
||||
rn, ok := e.Tail().(*depgraph.Noun).Meta.(*GraphNodeResource)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if rn.Resource.Diff == nil || rn.Resource.Diff.Empty() {
|
||||
continue
|
||||
}
|
||||
edges = append(edges, e)
|
||||
}
|
||||
} else {
|
||||
edges = n.Edges()
|
||||
}
|
||||
|
||||
// Do not draw if we have no edges
|
||||
if len(edges) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, e := range edges {
|
||||
target := e.Tail()
|
||||
edgeBuf.WriteString(fmt.Sprintf(
|
||||
"\t\"%s\" -> \"%s\";\n",
|
||||
n,
|
||||
target))
|
||||
}
|
||||
}
|
||||
if edgeBuf.Len() > 0 {
|
||||
buf.WriteString(edgeBuf.String())
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
}
|
||||
|
||||
func graphDotAddResourceProviders(buf *bytes.Buffer, g *depgraph.Graph) {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
layout: "docs"
|
||||
page_title: "Command: apply"
|
||||
sidebar_current: "docs-commands-apply"
|
||||
---
|
||||
|
||||
# Command: apply
|
||||
|
||||
The `terraform apply` command is used to apply the changes required
|
||||
to reach the desired state of the configuration, or the pre-determined
|
||||
set of actions generated by a `terraform plan` execution plan.
|
||||
|
||||
## Usage
|
||||
|
||||
Usage: `terraform apply [options] [dir]`
|
||||
|
||||
By default, `apply` scans the current directory for the configuration
|
||||
and applies the changes appropriately. However, a path to another configuration
|
||||
or an execution plan can be provided. Execution plans can be used to only
|
||||
execute a pre-determined set of actions.
|
||||
|
||||
The command-line flags are all optional. The list of available flags are:
|
||||
|
||||
* `-no-color` - Disables output with coloring.
|
||||
|
||||
* `-state=path` - Path to the state file. Defaults to "terraform.tfstate".
|
||||
|
||||
* `-state-out=path` - Path to write updated state file. By default, the
|
||||
`-state` path will be used.
|
||||
|
||||
* `-var 'foo=bar'` - Set a variable in the Terraform configuration. This
|
||||
flag can be set multiple times.
|
||||
|
||||
* `-var-file=foo` - Set variables in the Terraform configuration from
|
||||
a file. If "terraform.tfvars" is present, it will be automatically
|
||||
loaded if this flag is not specified.
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
layout: "docs"
|
||||
page_title: "Command: graph"
|
||||
sidebar_current: "docs-commands-graph"
|
||||
---
|
||||
|
||||
# Command: graph
|
||||
|
||||
The `terraform graph` command is used to generate a visual
|
||||
representation of either a configuration or execution plan.
|
||||
The output is in the DOT format, which can be used by
|
||||
GraphViz to generate charts.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Usage: `terraform output [options] [input]`
|
||||
|
||||
By default, `output` scans the current directory for the configuration
|
||||
and generates the output for that configuration. However, a path to
|
||||
another configuration or an execution plan can be provided. Execution plans
|
||||
provide more details on creation, deletion or changes.
|
||||
|
||||
## Generating Images
|
||||
|
||||
The output of `terraform graph` is in the DOT format, which can
|
||||
easily be converted to an image by making use of `dot` provided
|
||||
by GraphViz:
|
||||
|
||||
```
|
||||
$ terraform graph | dot -Tpng > graph.png
|
||||
```
|
||||
|
||||
Alternatively, the webbased [GraphViz Workspace](http://graphviz-dev.appspot.com)
|
||||
can be used to quickly render DOT file inputs as well.
|
||||
|
||||
Here is an example graph output:
|
||||
![Graph Example](/images/graph-example.png)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
layout: "docs"
|
||||
page_title: "Command: output"
|
||||
sidebar_current: "docs-commands-output"
|
||||
---
|
||||
|
||||
# Command: output
|
||||
|
||||
The `terraform output` command is used to extract the value of
|
||||
an output variable from the state file.
|
||||
|
||||
## Usage
|
||||
|
||||
Usage: `terraform output [options] NAME`
|
||||
|
||||
By default, `plan` requires only a variable name and looks in the
|
||||
current directory for the state file to query.
|
||||
|
||||
The command-line flags are all optional. The list of available flags are:
|
||||
|
||||
* `-state=path` - Path to the state file. Defaults to "terraform.tfstate".
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
layout: "docs"
|
||||
page_title: "Command: plan"
|
||||
sidebar_current: "docs-commands-plan"
|
||||
---
|
||||
|
||||
# Command: plan
|
||||
|
||||
The `terraform plan` command is used to create an execution plan. Terraform
|
||||
performs a refresh, unless explicitly disabled, and then determines what
|
||||
actions are necessary to achieve the desired state specified in the
|
||||
configuration files. The plan can be saved using `-out`, and then provided
|
||||
to `terraform apply` to ensure only the pre-planned actions are executed.
|
||||
|
||||
## Usage
|
||||
|
||||
Usage: `terraform plan [options] [dir]`
|
||||
|
||||
By default, `plan` requires no flags and looks in the current directory
|
||||
for the configuration and state file to refresh.
|
||||
|
||||
The command-line flags are all optional. The list of available flags are:
|
||||
|
||||
* `-destroy` - If set, generates a plan to destroy all the known resources.
|
||||
|
||||
* `-no-color` - Disables output with coloring.
|
||||
|
||||
* `-out=path` - The path to save the generated execution plan.
|
||||
|
||||
* `-refresh=true` - Update the state prior to checking for differences.
|
||||
|
||||
* `-state=path` - Path to the state file. Defaults to "terraform.tfstate".
|
||||
|
||||
* `-var 'foo=bar'` - Set a variable in the Terraform configuration. This
|
||||
flag can be set multiple times.
|
||||
|
||||
* `-var-file=foo` - Set variables in the Terraform configuration from
|
||||
a file. If "terraform.tfvars" is present, it will be automatically
|
||||
loaded if this flag is not specified.
|
||||
|
|
@ -27,7 +27,9 @@ The following arguments are supported:
|
|||
* `availability_zone` - (Optional) The AZ to start the instance in.
|
||||
* `instance_type` - (Required) The type of instance to start
|
||||
* `key_name` - (Optional) The key name to use for the instance.
|
||||
* `security_groups` - (Optional) A list of security group IDs to associate with.
|
||||
* `security_groups` - (Optional) A list of security group IDs or names to associate with.
|
||||
If you are within a VPC, you'll need to use the security group ID. Otherwise,
|
||||
for EC2, use the security group name.
|
||||
* `subnet_id` - (Optional) The VPC Subnet ID to launch in.
|
||||
* `source_dest_check` - (Optional) Controls if traffic is routed to the instance when
|
||||
the destination address does not match the instance. Used for NAT or VPNs. Defaults false.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
Loading…
Reference in New Issue