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
Once you import the state, you should be able to run the state show command to get a hint of the attributes to use in the config. Check out some third party libraries such as Terraformer that can help generate config.
Great question. If the config is wrong, when you run terrafrom plan, you will see a diff. Once you run terrafrom plan and it gives you the message that there is no change in the infrastructure then you know everything is correct.
A simple walkthrough of technologies we use like this is always greatly appreciated !
Thank you!
Great video, it really helped me to understand 'tf import' much better. Regards from Argentina!
Glad it helped, Bernardo! All the best to you!
Thanks, Sir! Very informative!
You’re welcome!
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
Once you import the state, you should be able to run the state show command to get a hint of the attributes to use in the config. Check out some third party libraries such as Terraformer that can help generate config.
Thank you! very clear and well explained :)
Thank you!
Great video tutorial!
Thank you! Cheers!
Thanks for the video!
my pleasure!
What happens if your config file is wrong when you run terraform import? is there any way to iterate to get it right.
Great question. If the config is wrong, when you run terrafrom plan, you will see a diff. Once you run terrafrom plan and it gives you the message that there is no change in the infrastructure then you know everything is correct.