github.com/ns1/terraform@v0.7.10-0.20161109153551-8949419bef40/website/source/docs/import/usage.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Import: Usage" 4 sidebar_current: "docs-import-usage" 5 description: |- 6 The `terraform import` command is used to import existing infrastructure. 7 --- 8 9 # Import Usage 10 11 The `terraform import` command is used to import existing infrastructure. 12 13 The command currently can only import one resource at a time. This means 14 you can't yet point Terraform import to an entire collection of resources 15 such as an AWS VPC and import all of it. A future version of Terraform will 16 be able to do this. 17 18 Using `terraform import` is simple. An example is shown below: 19 20 ``` 21 $ terraform import aws_instance.bar i-abcd1234 22 ... 23 ``` 24 25 ~> **Note:** In order to import resources, the provider should be configured with environment variables. 26 We currently do not support passing credentials directly to the provider. 27 28 The above command imports an AWS instance with the given ID to the 29 address `aws_instance.bar`. You can also import resources into modules. 30 See the [resource addressing](/docs/internals/resource-addressing.html) 31 page for more details on the full range of addresses supported. 32 33 The ID given is dependent on the resource type being imported. For example, 34 AWS instances use their direct IDs. However, AWS Route53 zones use the 35 domain name itself. Reference the resource documentation for details on 36 what the ID it expects is. 37 38 As a result of the above command, the resource is put into the state file. 39 If you run `terraform plan`, you should see Terraform plan your resource 40 for destruction. You now have to create a matching configuration so that 41 Terraform doesn't plan a destroy. 42 43 ## Complex Imports 44 45 The above import is considered a "simple import": one resource is imported 46 into the state file. An import may also result in a "complex import" where 47 multiple resources are imported. For example, an AWS security group imports 48 an `aws_security_group` but also one `aws_security_group_rule` for each rule. 49 50 In this case, the name of the resource is shown as part of the import output. 51 You'll have to create a configuration for each resource imported. If you want 52 to rename or otherwise modify the imported resources, the 53 [state management commands](/docs/commands/state/index.html) should be used.