How to use Terraform Import the Right Way

preview_player
Показать описание
Learn how to use #terraform import the right way in this video.

Suppose an engineer on your team decided to create an EC2 instance in #aws directly via the console and without using Terraform.

Terraform doesn't know anything about this resource and therefore won't know to add it to its state file.

Now there is a way to terraform import this resource into our state file, but we still need to manually write the configuration for it. If you don't, you could delete that resource!

This video lecture has been taken from my course:

▬▬▬▬▬▬ T I M E S T A M P S ⏰ ▬▬▬▬▬▬
00:00 - Introduction
02:22 - Terraform Import Docs
04:30 - Create EC2 Instance from Console
07:18 - Run Terraform Import Command
08:26 - Create the Terraform Configuration
11:39 - Wrap-up

▬▬▬▬▬▬▬▬ Useful Links 🛠 ▬▬▬▬▬▬▬

▬▬▬▬▬▬▬▬▬ Courses 🎓 ▬▬▬▬▬▬▬▬
🎟️ Get 15% off of my Vault 101 Course with this coupon ► YOUTUBE15VAULT101

🎟️ Get 15% off of my Terraform 101 Course with this coupon ► YOUTUBE15TF101

▬▬▬▬▬▬▬▬ Community 🌎 ▬▬▬▬▬▬▬▬▬

▬▬▬▬▬▬▬▬ Connect 👋 ▬▬▬▬▬▬▬▬▬
Рекомендации по теме
Комментарии
Автор

A simple walkthrough of technologies we use like this is always greatly appreciated !

faltuaccount
Автор

Great video, it really helped me to understand 'tf import' much better. Regards from Argentina!

bernardoteisceira
Автор

It's easier to add an 'empty' resource to your config before doing the import, like this:

resource "aws_instance" "console" {}

Then after the import you do this to see the actual state:

terraform state show aws_instance.console

You can then copy and paste that output into your config. You'll need to tweak it slightly and remove some of unnecessary attributes, but it much simpler than having to manually generate the config

AndyMadge
Автор

Thank you! very clear and well explained :)

jeydrn
Автор

What happens if your config file is wrong when you run terraform import? is there any way to iterate to get it right.

PeterGaard