First let’s create a variable file. This file will store all variables definitions, descriptions, types and validations.
variables.tf
variable "location" {
type = string
description = "Resources location"
}
variable "domain_name" {
default = "example.dev"
type = string
description = "Domain name for the dns zone"
}
After that, create a file and add to it the resource group creation code.
rg.tf
resource "azurerm_resource_group" "this" {
name = "rg-resource-group-name"
location = var.location
}
And finally create your dns zone.
dns.tf
resource "azurerm_dns_zone" "this" {
name = var.domain_name
resource_group_name = azurerm_resource_group.this.name
}
Go to My Domains/yourdomain.dev/DNS/
Select the custom name server
and add the azure name servers. They are visible in the Azure DNS zone panel like ns1-08.azure-dns.com
.