15 YouTube views, likes subscribers in 10 minutes. Free!
Get Free YouTube Subscribers, Views and Likes

How to import existing AWS resources into Terraform? | Terraform Import existing AWS Resources

Follow
DevOps Coach

https://www.coachdevops.com/2021/06/h...
The terraform import command is used to import existing infrastructure. The command currently can only import one resource at a time. This means you can't yet point Terraform import to an entire collection of resources such as an AWS VPC and import all of it.

Let's say that you have created EC2 instances manually outside Terraform. If you like to import your EC2 instance to Terraform you can use import command and bring it under Terraform state file.

To import a resource, create a tf file first write a resource block for it in your configuration, establishing the name by which it will be known to Terraform:

sudo vi myec2.tf
resource "aws_instance" "myinstance" {
...instance configuration...leave this as it is
}

posted by vacationqy