# Edge DNS resources

[View in Terraform Registry](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/intelligent_dns_zone)

The Azion Terraform Provider manages [Edge DNS](/en/documentation/platform/edge-dns/) with three resources and reads it with four data sources. A zone holds the records of a domain, and DNSSEC adds a layer of security to a zone. The identifiers keep the `intelligent_dns` form that the provider uses, and they have the same names in provider v1.x and v2.0. For more information, refer to [Migrate from provider v1.x to v2.0](/en/documentation/devtools/terraform/terraform-migration-v3-to-v4/).

---

## Edge DNS resources

| Resource                                                                                                                               | Description                            |
| -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
| [`azion_intelligent_dns_zone`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/intelligent_dns_zone)     | Creates and manages a DNS zone.        |
| [`azion_intelligent_dns_record`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/intelligent_dns_record) | Creates and manages a DNS record.      |
| [`azion_intelligent_dns_dnssec`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/resources/intelligent_dns_dnssec) | Manages the DNSSEC settings of a zone. |

Each resource takes its settings in one nested block: `zone`, `record`, or `dnssec`. The record and DNSSEC resources also take `zone_id` outside the block, and they read it from the `id` attribute of the zone resource.

| Resource                       | Argument             | Type            | Required | Description                                                                                             |
| ------------------------------ | -------------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------- |
| `azion_intelligent_dns_zone`   | `zone.name`          | String          | Yes      | The name that identifies the zone in lists. It is not the domain.                                       |
| `azion_intelligent_dns_zone`   | `zone.domain`        | String          | Yes      | The domain that the zone serves, such as `example.com`.                                                 |
| `azion_intelligent_dns_zone`   | `zone.active`        | Boolean         | Yes      | Sets whether the zone answers queries for its domain.                                                   |
| `azion_intelligent_dns_record` | `zone_id`            | String          | Yes      | The ID of the zone that holds the record.                                                               |
| `azion_intelligent_dns_record` | `record.name`        | String          | Yes      | The name of the record, relative to the zone, such as `www`.                                            |
| `azion_intelligent_dns_record` | `record.type`        | String          | Yes      | The record type, such as `A`, `AAAA`, or `CNAME`.                                                       |
| `azion_intelligent_dns_record` | `record.rdata`       | List of strings | Yes      | One or more answers of the record.                                                                      |
| `azion_intelligent_dns_record` | `record.policy`      | String          | Yes      | `simple` answers with every value of the record. `weighted` lets several records share a name and type. |
| `azion_intelligent_dns_record` | `record.ttl`         | Number          | Yes      | The time to live of the record, in seconds.                                                             |
| `azion_intelligent_dns_record` | `record.weight`      | Number          | No       | The weight of the record. It applies only when `policy` is `weighted`.                                  |
| `azion_intelligent_dns_record` | `record.description` | String          | No       | The description of the record, for either `policy`.                                                     |
| `azion_intelligent_dns_dnssec` | `zone_id`            | String          | Yes      | The ID of the zone.                                                                                     |
| `azion_intelligent_dns_dnssec` | `dnssec.is_enabled`  | Boolean         | Yes      | Sets whether DNSSEC is on for the zone.                                                                 |

A `simple` record takes `description` from provider 2.10.0. Versions 2.0.0 to 2.9.0 send `description` only for `weighted` records, so a `simple` record with a description fails on `terraform apply`. The provider stores an empty `description` as unset.

For every record type, refer to [Record types](/en/documentation/platform/edge-dns/record-types/). For the limits of each field, refer to [Zones and records](/en/documentation/platform/edge-dns/zones-and-records/). The Terraform Registry page of each resource lists every argument.

---

## Data sources

| Data source                                                                                                                                 | Description                          |
| ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| [`azion_intelligent_dns_zones`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/data-sources/intelligent_dns_zones)     | Lists DNS zones.                     |
| [`azion_intelligent_dns_zone`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/data-sources/intelligent_dns_zone)       | Reads one DNS zone.                  |
| [`azion_intelligent_dns_records`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/data-sources/intelligent_dns_records) | Lists DNS records.                   |
| [`azion_intelligent_dns_dnssec`](https://registry.terraform.io/providers/aziontech/azion/latest/docs/data-sources/intelligent_dns_dnssec)   | Reads the DNSSEC settings of a zone. |

---

## Example

This configuration pins provider 2.10.0 and creates a zone with an `A` record and a `CNAME` record. It turns on DNSSEC for the zone and outputs the zone ID. The `A` record carries a `description`, which a `simple` record takes from provider 2.10.0. The configuration reads your personal token from the `api_token` variable that the [Azion Terraform Provider quickstart](/en/documentation/devtools/terraform/getting-started/) declares.

```hcl
terraform {
  required_providers {
    azion = {
      source  = "aziontech/azion"
      version = "2.10.0"
    }
  }
}

provider "azion" {
  api_token = var.api_token
}

# Create DNS zone
resource "azion_intelligent_dns_zone" "my_zone" {
  zone = {
    name   = "example-zone"
    domain = "example.com"
    active = true
  }
}

# Create A record
resource "azion_intelligent_dns_record" "www" {
  zone_id = azion_intelligent_dns_zone.my_zone.id
  record = {
    name        = "www"
    type        = "A"
    rdata       = ["192.0.2.1"]
    policy      = "simple"
    ttl         = 3600
    description = "Web server"
  }
}

# Create CNAME record
resource "azion_intelligent_dns_record" "alias" {
  zone_id = azion_intelligent_dns_zone.my_zone.id
  record = {
    name   = "alias"
    type   = "CNAME"
    rdata  = ["www.example.com"]
    policy = "simple"
    ttl    = 3600
  }
}

# Enable DNSSEC
resource "azion_intelligent_dns_dnssec" "my_dnssec" {
  zone_id = azion_intelligent_dns_zone.my_zone.id
  dnssec = {
    is_enabled = true
  }
}

output "zone_id" {
  value = azion_intelligent_dns_zone.my_zone.id
}
```

---

## Related resources

- [Resources and data sources](/en/documentation/devtools/terraform/examples.md): Every resource and data source of the provider, with an example per family.
- [Security resources](/en/documentation/devtools/terraform/security.md): The resources that manage firewalls, WAF settings, and network lists.
- [Certificates resources](/en/documentation/devtools/terraform/certificates.md): The resources that manage digital certificates.
- [Applications resources](/en/documentation/devtools/terraform/applications.md): The resources that manage applications and their settings.
