-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
layout: "docs" | ||
page_title: "Import: Resource Importability" | ||
sidebar_current: "docs-import-importability" | ||
description: |- | ||
Each resource in Terraform must implement some basic logic to become | ||
importable. As a result, not all Terraform resources are currently importable. | ||
--- | ||
|
||
# Resource Importability | ||
|
||
Each resource in Terraform must implement some basic logic to become | ||
importable. As a result, not all Terraform resources are currently importable. | ||
If you find a resource that you want to import and Terraform reports | ||
that it isn't importable, please report an issue. | ||
|
||
Converting a resource to be importable is also relatively simple, so if | ||
you're interested in contributing that functionality, the Terraform team | ||
would be grateful. | ||
|
||
To make a resource importable, please see the | ||
[plugin documentation on writing a resource](/docs/plugins/provider.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
layout: "docs" | ||
page_title: "Import" | ||
sidebar_current: "docs-import" | ||
description: |- | ||
Terraform is able to import existing infrastructure. This allows you take | ||
resources you've created by some other means and bring it under Terraform | ||
management. | ||
--- | ||
|
||
# Import | ||
|
||
Terraform is able to import existing infrastructure. This allows you take | ||
resources you've created by some other means and bring it under Terraform | ||
management. | ||
|
||
This is a great way to slowly transition infrastructure to Terraform, or | ||
to be able to be confident that you can use Terraform in the future if it | ||
potentially doesn't support every feature you need today. | ||
|
||
## Currently State Only | ||
|
||
The current implementation of Terraform import can only import resources | ||
into the [state](/docs/state). It does not generate configuration. A future | ||
version of Terraform will also generate configuration. | ||
|
||
Because of this, the behavior of importing resources into Terraform right now | ||
is that after an import, if you run a `terraform plan`, Terraform views it | ||
as an orphan (a resource with no configuration) and marks it for destruction. | ||
After importing a resource you have to manually write configuration to match | ||
the resource. | ||
|
||
While this may seem tedious, it still gives Terraform users an avenue for | ||
importing existing resources. A future version of Terraform will fully generate | ||
configuration significantly simplifying this process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
layout: "docs" | ||
page_title: "Import: Usage" | ||
sidebar_current: "docs-import-usage" | ||
description: |- | ||
The `terraform import` command is used to import existing infrastructure. | ||
--- | ||
|
||
# Import Usage | ||
|
||
The `terraform import` command is used to import existing infrastructure. | ||
|
||
The command currently can only import one resource at a time. This means | ||
you can't yet point Terraform import to an entire collection of resources | ||
such as an AWS VPC and import all of it. A future version of Terraform will | ||
be able to do this. | ||
|
||
Using `terraform import` is simple. An example is shown below: | ||
|
||
``` | ||
$ terraform import aws_instance.bar i-abcd1234 | ||
... | ||
``` | ||
|
||
The above command imports an AWS instance with the given ID to the | ||
address `aws_instance.bar`. You can also import resources into modules. | ||
See the [resource addressing](/docs/internals/resource-addressing.html) | ||
page for more details on the full range of addresses supported. | ||
|
||
The ID given is dependent on the resource type being imported. For example, | ||
AWS instances use their direct IDs. However, AWS Route53 zones use the | ||
domain name itself. Reference the resource documentation for details on | ||
what the ID it expects is. | ||
|
||
As a result of the above command, the resource is put into the state file. | ||
If you run `terraform plan`, you should see Terraform plan your resource | ||
for destruction. You now have to create a matching configuration so that | ||
Terraform doesn't plan a destroy. | ||
|
||
## Complex Imports | ||
|
||
The above import is considered a "simple import": one resource is imported | ||
into the state file. An import may also result in a "complex import" where | ||
multiple resources are imported. For example, an AWS security group imports | ||
an `aws_security_group` but also one `aws_security_group_rule` for each rule. | ||
|
||
In this case, the name of the resource is shown as part of the import output. | ||
You'll have to create a configuration for each resource imported. If you want | ||
to rename the other imported resources, the | ||
[state management commands](/docs/commands/state/index.html) should be used | ||
to rename resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters