Creating a resource record
A TXT record may not exceed 1,024 characters in length.
To create a resource record in a DNS zone:
- In the management console
, select the folder containing the DNS zone to create a record in. - Select Cloud DNS.
- Select the zone from the list.
- Click Create record.
- Set the record parameters:
- In the Name field, enter a name for the record.
- Select a record type from the drop-down list.
- In the TTL (in seconds) field, specify the record time to live or select a value from the list.
- Enter a Data for the record.
- Click Create.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
Run this command:
yc dns zone add-records --name <DNS_zone_name> \
--record "<domain_name> <TTL> <record_type> <value>"
Example
Creating a TXT record with a DKIM signature:
yc dns zone add-records test-zone \ --record "test-record TXT v=DKIM1;k=rsa;p=MIIBIjAN...gkH2v1NTgQdTKfPmDK...YdRiwIDAQAB"
If your TXT record contains multiple values, enclose each one in double quotes (""
):
yc dns zone add-records test-zone \ --record "test-record TXT v=DKIM1;k=rsa;p=MIIBIjAN""gkH2v1NTgQdTKfPmDK""YdRiwIDAQAB"
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the parameters of resources that you want to create: You can add multiple records at the same time.
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"] } 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:
-
yandex_dns_zone
parameters:zone
: Domain zone. The zone name must end with a dot. You cannot create public top-level domain (TLD) zones. This is a required parameter.folder_id
: ID of the folder to create a zone in. If not specified, the default folder is used. This is an optional parameter.name
: Zone name. It must be unique within the folder. This is an optional parameter.description
: Zone description. This is an optional parameter.labels
: Set of DNS zone labels. This is an optional parameter.public
: Zone visibility, public or private. This is an optional parameter.private_networks
: For a public zone, specify the Virtual Private Cloud resources that this zone is visible to. This is an optional parameter.
-
yandex_dns_recordset
parameters:zone_id
: ID of the zone where the record set will be located. This is a required parameter.name
: Domain name. This is a required parameter.type
: DNS record type. This is a required parameter.ttl
: Record time to live (TTL) in seconds before updating the record value. This is an optional parameter.data
: Record value. This is an optional parameter.
For more information about resources you can create with Terraform, see the provider documentation
. -
-
Apply the changes:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
Terraform will create all the required resources. You can check the new resources using the management console
or this CLI command:yc dns zone list-records <zone_name>
-
To create a resource record in a DNS zone, use the updateRecordSets REST API method for the DnsZone resource or the DnsZoneService/UpdateRecordSets gRPC API call.
When creating AAAA resource records, the service automatically normalizes IPv6 addresses by replacing the gaps between :
with zeros. For example: 2001:db8::
→ 2001:db8:0:0:0:0:0:0
.