O'Reilly logo

Getting Started with Terraform - Second Edition by Kirill Shirinkin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Importing resources

Sometimes, resources are created manually. For example, you might have had an existing AWS infrastructure in place before you decided to introduce Terraform to your company. Now you need to move it somehow under Terraform's control. One option is, of course, to just recreate everything. Not all the resources are that easy to recreate though. That's where the terraform import command will help us.

If you destroyed it before, then rerun the template to create a new VPC. Then, create a new NAT gateway manually from the AWS Management Console:

To import it, we need to know the ID of this gateway:

Copy it and go back to the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required