It was an awesome video. One thing you have to make very clear in your video that "terraform import" will never give you terraform code, it just import the current state into your state file. Reconstructing the code as in your case was so easy because you created a very basic EC2 instance. If you want to do the same thing in a complex environment, writing complex terraform code is still on your head even after using "terraform import".
Thanks Rahul, awesome tutorial. I got access to 2 udemy courses for terraform but none of them are this lucid & clear. This shud be called - Terraform Made Easy by Rahul Wagh :D
Great explanation with example ❤.Though I have used the terraform import earlier it clears my concept a bit more. Btw: I was expecting when I will run terraform import it will automatically reconstruct my resources also 😂
Yeah it’s absolutely true. It is very difficult to use terraform import on very large project. You should always use this for debugging troubleshooting purposes
Error: resource address "aws_instance.ec2_example" does not exist in the configuration. Before importing this resource, please create its configuration in the root module. For example: resource "aws_instance" "ec2_example" { # (resource arguments) Getting this error while importing, what is the root module.
Hey, There is person A, who created few resources through terraform nd all those resources have been recorded in statefile. Now this person A, made some resources manually and did not use terraform, so all those manually created resources have not been recorded in statefile. Now, person B comes, he doesn't know what all resources have been manually added and now his job is to import all those manually added resources to the terraform in statefile. So, my question is - is there any way that person B can figure out what all resources have been changed manually??
Terraform import is not very widely covered topic, thanks for sharing this session. Recently I was searching Amazon for the best book that I can purchase for Ansible, and I was looking for someone, who can guide me on this, i just can not unnoticed the Ansible book you have on shelf. I have , Ansible for DevOps by Jeff Geerling , Ansible Playbook Essential by Gourav Shah and Mastering Ansible by Jesse Keating to choose from. I work on servers and used Ansible for Config Management and services orchestration, which book should I go for, is Ansible for DevOps covers all necessary topics ? Please guide.....
Thanks mate . It became very simple after you explain. Question : If I modify any imported resources using the terraform , will it work in real infra also ?
Thanks for posting interesting sessions on Terraforms.. Can you post some demos of using Templates for spinning up AWS instances or GCP instances. I am basically looking to see how we can define an Test Environment that consists of some components as Template and use this template to instantiate the actual Test Environment.....
Hi Rahul, I have below requirnment, I have enabled Cross account setting on my main monitoring account and now i want to run the CFT to enable Cross account Cross region setting on all other AWS account to share there metric data with monitoring account. For that we need to built the terraform code.. so will you please help with any link or document for the same. Regards Rajiv
Hi Rahul, I am having issues with importing aws Security Groups. Can you help with this please? When you have in ingress; ports 135-139. How do you code this please?
If we have to again define the resource block on our own even after doing import. What is the sense of then importing it ?? Is it just to update the state file ??
If you have imported the resources then i am assuming that the VPC is already setup on the AWS. But anyway after you have done the import, after that you simply need to run the terraform apply command.
Well data sources are always limited to the single resources although you can loop it but terraform import is cli(command line) utility to import more than one resource into your terraform code stack
It was an awesome video. One thing you have to make very clear in your video that "terraform import" will never give you terraform code, it just import the current state into your state file. Reconstructing the code as in your case was so easy because you created a very basic EC2 instance. If you want to do the same thing in a complex environment, writing complex terraform code is still on your head even after using "terraform import".
Hey Rahul,
Thanks for this awesome tutorial, I had interview yesterday on terraform and got selected today by following ur tutorials. Many thanks.
Gr8 to hear that and i wish you a good luck with the new job
The way you are explaining any skill set , it's awesome . I learned terraform in a week from your youtube channel.
That's awesome!
How to import dynamically
Thanks Rahul, awesome tutorial. I got access to 2 udemy courses for terraform but none of them are this lucid & clear. This shud be called - Terraform Made Easy by Rahul Wagh :D
You are welcome
Best Terraform Teacher
Cheers!
Thanks for such a great explaination.
Glad it was helpful!
Nice explanation and practical!!
Superb as always !
Thank you! Cheers!
very helpful video - thank you
@Rahul very nice explanation.
You are welcome
Great explanation with example ❤.Though I have used the terraform import earlier it clears my concept a bit more. Btw: I was expecting when I will run terraform import it will automatically reconstruct my resources also 😂
NO it will not reconstruct the resource
@@RahulWagh Yes I know but that was my expectations actually 😂, thanks for the reply 👍
@Rahul terraform import command will be challenging to use in complex arch rite . Thanks for the video. Keep rocking.....
Yeah it’s absolutely true. It is very difficult to use terraform import on very large project. You should always use this for debugging troubleshooting purposes
in terraform 1.5, import block is newly added which makes it easier with 'id' & 'to'. Alhamdullilah :)
The video is getting older now so yes it has changed
Very useful! Thanks a lot! :)
Error: resource address "aws_instance.ec2_example" does not exist in the configuration.
Before importing this resource, please create its configuration in the root module. For example:
resource "aws_instance" "ec2_example" {
# (resource arguments)
Getting this error while importing, what is the root module.
Thanks for the video. Could you also talk about "config-driven" import in Terraform?
Hey,
There is person A, who created few resources through terraform nd all those resources have been recorded in statefile. Now this person A, made some resources manually and did not use terraform, so all those manually created resources have not been recorded in statefile.
Now, person B comes, he doesn't know what all resources have been manually added and now his job is to import all those manually added resources to the terraform in statefile.
So, my question is - is there any way that person B can figure out what all resources have been changed manually??
Many many thanks.
You are most welcome
Terraform import is not very widely covered topic, thanks for sharing this session.
Recently I was searching Amazon for the best book that I can purchase for Ansible, and I was looking for someone, who can guide me on this, i just can not unnoticed the Ansible book you have on shelf.
I have , Ansible for DevOps by Jeff Geerling , Ansible Playbook Essential by Gourav Shah and Mastering Ansible by Jesse Keating to choose from.
I work on servers and used Ansible for Config Management and services orchestration, which book should I go for, is Ansible for DevOps covers all necessary topics ? Please guide.....
Can we import entire S3 resources to terraform state in one go? or do we need to do one by one s3 buckets import?
If you know all the attributes then you can do in one go otherwise you have to go one by one
After import which file gets updated ? Statefile ?
Thanks mate . It became very simple after you explain.
Question : If I modify any imported resources using the terraform , will it work in real infra also ?
Thanks for posting interesting sessions on Terraforms.. Can you post some demos of using Templates for spinning up AWS instances or GCP instances. I am basically looking to see how we can define an Test Environment that consists of some components as Template and use this template to instantiate the actual Test Environment.....
I am importing existing env in my state file but when I run it it recreate instances again which were already running or were in off state
super bro
Cheers
Difference between terraform pull & import?
Hi , how do we know what all necessary attributes needs to kept in the resources after importing?
Yes you need to know all the attribute
@@RahulWagh thanks and is there any command to import the whole infra at once eg. I have bunch of GCS buckets , bunch of vpc , compute engines etc..?
Hi Rahul,
I have below requirnment,
I have enabled Cross account setting on my main monitoring account and now i want to run the CFT to enable Cross account Cross region setting on all other AWS account to share there metric data with monitoring account. For that we need to built the terraform code.. so will you please help with any link or document for the same.
Regards
Rajiv
you should have also show tfstate file before and after import
Hi Rahul, I am having issues with importing aws Security Groups. Can you help with this please? When you have in ingress; ports 135-139. How do you code this please?
Can i use terraform instead of ansible ?
If we have to again define the resource block on our own even after doing import. What is the sense of then importing it ??
Is it just to update the state file ??
You do not understood the importance of the import block. You can still define the resource block even after the import
Hi @Rahul I am requesting you to complete all the topics based on TCA003 ToC. Thanks in Advance.
Hi Ankit if you have followd all the 22 session from terraform playlist then i think you should be able to crack Terraform TCA003 ToC
Can we delete existing aws resource using terraform, which is created manually? I asking for secrets from aws secret manager
how to use imported resources? i imported vpc but how do i use the vpc to launch instance?
If you have imported the resources then i am assuming that the VPC is already setup on the AWS. But anyway after you have done the import, after that you simply need to run the terraform apply command.
then what is the purpose of data block?
Well data sources are always limited to the single resources although you can loop it but terraform import is cli(command line) utility to import more than one resource into your terraform code stack
Is this course sufficient to crack terraform associate exam 003?
Yes it is if you have followed all the chapters
This really doesn't help in real time scenario😮😢