From the course: HashiCorp Certified: Terraform Associate (003) Cert Prep by KodeKloud

Unlock this course with a free trial

Join today to access over 23,400 courses taught by industry experts.

Terraform import

Terraform import

- [Instructor] Let us now take a quick look at how to import existing resources into Terraform. Terraform Import is used to bring resources created by other means into the management of Terraform. For example, within an AWS account, there may be several resources that are provisioned using Terraform. However, there may be resources that are created using the management console or by using another IEC tool such as Ansible. Now, these resources can be imported to Terraform using the terraform import command. Let us use an existing EC2 instance as an example that we want to import to Terraform. Now, as a prerequisite, we need a unique attribute for this resource before we can import it. The instance ID of the EC2 instance is one such attribute, so let's copy it so that we can use it later. One thing to keep in mind is that the terraform import command does not update the configuration files. It only imports resources into the state file. And as of this recording, the configuration files…

Contents