[Yandex Cloud documentation](../../index.md) > [Yandex Cloud DNS](../index.md) > [Step-by-step guides](index.md) > Records > Creating a record

# Creating a resource record

[TXT records](../concepts/resource-record.md#txt) have a maximum length of 1024 characters.

To create a [resource record](../concepts/resource-record.md) in a DNS zone:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder containing the DNS zone where you want to create a resource record.
  1. Navigate to **Cloud DNS**.
  1. Select the zone from the list.
  1. Click **Create record**.
  1. Specify the record settings:
     1. In the **Name** field, specify the record name.
     1. Select the [record type](../concepts/resource-record.md#rr-types) from the drop-down list.
     1. In the **TTL (in seconds)** field, select the record TTL (Time to Live) value from the dropdown list or specify a custom duration in seconds.
     1. Specify a **Data** for the record.
  1. Click **Create**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  Run this command:

  ```bash
  yc dns zone add-records --name <DNS_zone_name> \
    --record "<domain_name> <TTL> <record_type> <value>" \
    --description "<description>"
  ```

  Where:

  * `--name`: Zone name. It must be unique within a folder.
  * `--record`: DNS record containing the domain name, TTL, record type, and record value.
  * `--description`: Description for the new records. If this parameter is not set, the description will be an empty string. This is an optional setting.

  **Example**

  Creating a TXT record with a DKIM signature:

  > ```bash
  > yc dns zone add-records test-zone \
  >   --record "test-record TXT v=DKIM1;k=rsa;p=MIIBIjAN...gkH2v1NTgQdTKfPmDK...YdRiwIDAQAB"
  > ```

  Creating a record with a description:

  > ```bash
  >  yc dns zone add-records test-zone \
  >   --record "srv.example.com. 600 A 10.1.0.1" \
  >   --description "Web server"
  > ```

  If your TXT record contains multiple values, enclose each one in double quotes (`""`):

  > ```bash
  > yc dns zone add-records test-zone \
  >   --record "test-record TXT v=DKIM1;k=rsa;p=MIIBIjAN""gkH2v1NTgQdTKfPmDK""YdRiwIDAQAB"
  > ```

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../terraform/authentication.md) using the appropriate method.

  1. In the configuration file, describe the resources you want to create: You can add multiple entries at once.

     ```hcl
     resource "yandex_vpc_network" "foo" {}
     
     resource "yandex_dns_zone" "zone1" {
       name        = "my-private-zone"
       description = "desc"
     
       labels = {
         label1 = "label-1-value"
       }
     
       zone             = "example.com."
       public           = false
       private_networks = [yandex_vpc_network.foo.id]
     }
     
     resource "yandex_dns_recordset" "rs1" {
       zone_id     = yandex_dns_zone.zone1.id
       name        = "srv.example.com."
       type        = "A"
       ttl         = 200
       data        = ["10.1.0.1"]
       description = "Web server primary"
     }
     
     resource "yandex_dns_recordset" "rs2" {
       zone_id = yandex_dns_zone.zone1.id
       name    = "srv2"
       type    = "A"
       ttl     = 200
       data    = ["10.1.0.2"]
     }

     resource "yandex_dns_recordset" "rs_dkim" {
       zone_id = yandex_dns_zone.zone1.id
       name    = "dkim"
       type    = "TXT"
       ttl     = 200
       data    = ["v=DKIM1;k=rsa;t=s;p=MIIBIjAN...gkH2v1NTgQdTKfPmDK...YdRiwIDAQAB"]
     }
     ```

     Where:

     1. `yandex_dns_zone` settings:

        * `zone`: Domain zone. Note that the zone name must end with a trailing dot. You cannot create top-level domain (TLD) zones. This is a required setting.
        * `folder_id`: ID of the folder where you want to create your zone. If no folder is specified, the system will use the default one. This is an optional setting.
        * `name`: Zone name. It must be unique within the folder. This is an optional setting.
        * `description`: Zone description. This is an optional setting.
        * `labels`: DNS zone labels. This is an optional setting.
        * `public`: Zone visibility, public or private. This is an optional setting.
        * `private_networks`: For a public zone, specify the Virtual Private Cloud resources that can access this zone. This is an optional setting.

     1. `yandex_dns_recordset` settings:

        * `zone_id`: ID of the zone that will contain your resource records. This is a required setting.
        * `name`: Domain name. This is a required setting.
        * `type`: DNS record type. This is a required setting.
        * `ttl`: Record time to live (TTL) in seconds before refreshing the record value. This is an optional setting.
        * `data`: Record value. This is an optional setting.
        * `description`: Record set description. This is an optional setting.

     For more information about resources you can create with Terraform, see the [relevant provider documentation](../../terraform/index.md).

  1. Apply the changes:

      1. In the terminal, navigate to the configuration file directory.
      1. Make sure the configuration is correct using this command:
      
         ```bash
         terraform validate
         ```
      
         If the configuration is valid, you will get this message:
      
         ```bash
         Success! The configuration is valid.
         ```
      
      1. Run this command:
      
         ```bash
         terraform plan
         ```
      
         You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
      1. Apply the configuration changes:
      
         ```bash
         terraform apply
         ```
      
      1. Type `yes` and press **Enter** to confirm the changes.
  
     Terraform will create all the required resources. You can check the new resources in the [management console](https://console.yandex.cloud) or using this [CLI](../../cli/quickstart.md) command:

     ```bash
     yc dns zone list-records <zone_name>
     ```

- API {#api}

  To create a resource record in a DNS zone, use the [updateRecordSets](../api-ref/DnsZone/updateRecordSets.md) REST API method for the [DnsZone](../api-ref/DnsZone/index.md) resource or the [DnsZoneService/UpdateRecordSets](../api-ref/grpc/DnsZone/updateRecordSets.md) gRPC API call.

{% endlist %}

When creating AAAA resource records, the service automatically normalizes IPv6 addresses by filling omitted zeros between `:`, e.g., `2001:db8::` → `2001:db8:0:0:0:0:0:0`.