How to import your existing AWS Route53 Zone on Terraform
In this post I will explain how to import an AWS Route53 zone in your terraform project if you manage it on AWS.
I am assuming that you already have a terraform project on your workstation. If it is not the case, follow this link to create your first terraform project: https://learn.hashicorp.com/collections/terraform/aws-get-started
Using the command below, retrieve the list of your zone managed on AWS Route53 and identifiy the id of the zone you want to import in terraform.
You response should looks like below
From this response you can get the ID of your zone that we will need to use below. In this example the ID is Z3O0J2DXBE1FTB
3. Define the terraform providers needed
To work with the resource aws_route53_zone in terraform, your first need to defined a provider which can manage this resource. You should get a file providers.tf in your project containing the following configuration:
4. Import the Route53 zone in your terraform
Using the ID retrieve below we can import our zone in terraform. To do so we need to create and attribute a name to our aws_route53_zone resource, in my case “garygitton_fr”
The response should be like:
5. Create the terraform resource for the zone
In your terraform file main.tf, add the base configuration for the aws_route53_zone resource
6. Check the terraform plan
Using the command plan form terraform, verify the modification that will be bring
Output should be like:
7. Apply the modification
If the plan, is good for you, apply the modification as follow:
You should get a response like
You are all done
You just imported your AWS Route53 zone in your Terraform configuration.