Terraform Import

Terraform Import

Terraform Import

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed terraform locals.

https://cloudaffaire.com/terraform-locals/

In this blog post, we will discuss terraform import.

What is terraform import?

You can use terraform import to import your current existing infrastructure. This allows you to 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.

Note: The current implementation of Terraform import can only import resources into the state. It does not generate configuration.

Next, we are going to explain terraform import with a demo.

Terraform import:

Hope you have enjoyed this article. In the next blog post, we will discuss terraform refresh.

To get more details on terraform, please refer below terraform documentation.

https://www.terraform.io/docs/index.html

 

This Post Has 2 Comments

  1. Hi…i tried importing a vpc…but when i try to destroy it gives me an error like Error: aws_vpc.myimportedvpc: “cidr_block”: required field is not set..can you help me with this.

  2. Debjeet

    Dear Aakrash,

    Can you please provide your tf state file and import command that you have executed.
    You can try the import with CIDR block like below
    resource “aws_vpc” “myimportedvpc” {
    cidr_block = [“your_cidr_block”]
    }

    Thanks,
    Debjeet

Leave a Reply

Close Menu