website: add import command docs

This commit is contained in:
Mitchell Hashimoto 2016-05-18 12:56:51 -06:00
parent 6d9e41668f
commit 54df833406
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,69 @@
---
layout: "docs"
page_title: "Command: import"
sidebar_current: "docs-commands-import"
description: |-
The `terraform import` command is used to import existing resources into Terraform.
---
# Command: import
The `terraform import` command is used to
[import existing resources](/docs/import/index.html)
into Terraform.
## Usage
Usage: `terraform import [options] ADDRESS ID`
Import will find the existing resource from ID and import it into your Terraform
state at the given ADDRESS.
ADDRESS must be a valid [resource address](/docs/internals/resource-addressing.html).
Because any resource address is valid, the import command can import resources
into modules as well directly into the root of yor state.
ID is dependent on the resource type being imported. For example, for AWS
instances it is the instance ID (`i-abcd1234`) but for AWS Route53 zones
it is the domain. Please reference the provider documentation for details
on the ID format. If you're unsure, feel free to just try an ID. If the ID
is invalid, you'll just receive an error message.
The command-line flags are all optional. The list of available flags are:
* `-backup=path` - Path to backup the existing state file. Defaults to
the `-state-out` path with the ".backup" extension. Set to "-" to disable
backups.
* `-input=true` - Whether to ask for input for provider configuration.
* `-state=path` - The path to read and save state files (unless state-out is
specified).
* `-state-out=path` - Path to write the final state file. By default, this is
the state path.
## Provider Configuration
To access the provider that the resource is being imported from, Terraform
will ask you for access credentials. If you don't want to be asked for input,
verify that all environment variables for your provider are set.
The import command cannot read provider configuration from a Terraform
configuration file.
## Example: AWS Instance
This example will import an AWS instance:
```
$ terraform import aws_instance.foo i-abcd1234
```
## Example: Import to Module
The example below will import an AWS instance into a module:
```
$ terraform import module.foo.aws_instance.bar i-abcd1234
```

View File

@ -83,6 +83,10 @@
<a href="/docs/commands/graph.html">graph</a>
</li>
<li<%= sidebar_current("docs-commands-import") %>>
<a href="/docs/commands/import.html">import</a>
</li>
<li<%= sidebar_current("docs-commands-init") %>>
<a href="/docs/commands/init.html">init</a>
</li>