How to Use Terraform with Existing Infrastructure
Using Terraform with existing infrastructure.
Add the existing resource to your Terraform file:
resource "aws_route53_zone" "primary_zone" {
name = var.root_domain
}
Then run aws cli command to get the ID:
terraform import aws_route53_zone.primary_zone <resource id>
This adds the resource to your state file, as if it had been managed by Terraform all along.