MENU

Fun & Interesting

How to Use Terraform Import Command | Bring Existing Infrastructure into Your IaC Code

TheCodeCloud 121 lượt xem 1 month ago
Video Not Working? Fix It Now

In this video, we’ll explore the **Terraform `import` command**, a powerful feature that allows you to bring existing cloud infrastructure under Terraform management. Whether you’re migrating resources or recovering state, this tutorial will guide you through the process step by step.

🔹 **What You’ll Learn:**
✅ What the `terraform import` command does and when to use it
✅ Step-by-step demo: Importing an GCP Compute instance
✅ How to write Terraform configuration to match imported resources
✅ Best practices & common pitfalls to avoid

📌 **Commands Used in This Video:**
```sh
terraform import google_compute_instance.imported_instance projects/[PROJECT_ID]/zones/[ZONE]/instances/[INSTANCE_NAME]
# Example:
terraform import google_compute_instance.imported_instance projects/my-gcp-project-451114/zones/us-central1-a/instances/thecodeclouds-gce
```

🔗 **Helpful Links:**
- https://thecodeclouds.com/terraform-import-command-with-google-cloud-instance
- https://thecodeclouds.com
- [Terraform Import Documentation](https://developer.hashicorp.com/terraform/cli/import)
- [Terraform GCP Provider](https://registry.terraform.io/providers/hashicorp/google/latest/docs)

💬 **Got Questions?** Drop them in the comments below!

👍 **Like & Subscribe** for more DevOps, Terraform, and cloud automation content!

#Terraform #DevOps #InfrastructureAsCode #CloudComputing #AWS #TerraformImport #IAC

Comment