Creating a resource record
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:
- Domain name.
- Record type.
- Record TTL.
- Record value.
- Click Create.
If you don't 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 the command:
yc dns zone add-records --name <DNS zone name> \
--record "<domain name> <TTL> <record type> <value>"
You can add multiple records at the same time.
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.
yandex_dns_zone
parameters:zone
: Domain zone. The zone name must end with a dot. You can't create public top-level domain (TLD) zones. Required parameter.folder_id
: ID of the folder to create a zone in. If not specified, the default folder is used. Optional.name
: Zone name. It must be unique within the folder. Optional.description
: Zone description. Optional.labels
: A set of DNS zone labels. Optional.public
: Zone visibility (public or internal). Optional.private_networks
: For a public zone, specify the Virtual Private Cloud resources that this zone is visible to. Optional.
yandex_dns_recordset
parameters:zone_id
: ID of the zone where the record set will be located. Required parameter.name
: Domain name. Required parameter.type
: DNS record type. Required parameter.ttl
: Record time to live (TTL) in seconds before updating the record value. Optional.data
: Record value. Optional.
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"] }
For more information about resources you can create with Terraform, see the provider documentation.
-
Run the check using the command:
terraform plan
The terminal will display a list of resources with parameters. This is a test step. No resources are created. If there are errors in the configuration, Terraform points them out.
Alert
You're charged for all resources created using Terraform. Check the plan carefully.
-
To create resources, run the command:
terraform apply
-
Confirm the resource creation: type
yes
in the terminal and press Enter.Terraform creates all the required resources. You can check that the resources are there using the management console or the CLI command below:
yc dns zone list-records <DNS zone name>
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
.