Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
© 2022 Yandex.Cloud LLC
Yandex Cloud DNS
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Zones
      • Creating an internal DNS zone
      • Creating a public DNS zone
      • Updating a DNS zone
      • Deleting a DNS zone
    • Records
      • Creating a record
      • Updating a record
      • Deleting a record
  • Concepts
    • Overview
    • DNS zones
    • Resource records
    • Integration with Yandex Compute Cloud
    • Quotas and limits
  • Practical guidelines
    • Configuring a local caching DNS resolver
    • Migrating DNS zones from Yandex 360
    • Integrating with a corporate DNS service
    • Configuring Cloud DNS for access to managed database clusters from other cloud networks
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • DnsZoneService
      • OperationService
    • REST
      • Overview
      • DnsZone
        • Overview
        • create
        • delete
        • get
        • getRecordSet
        • list
        • listAccessBindings
        • listOperations
        • listRecordSets
        • setAccessBindings
        • update
        • updateAccessBindings
        • updateRecordSets
        • upsertRecordSets
  1. Step-by-step instructions
  2. Records
  3. Creating a record

Creating a resource record

Written by
Yandex Cloud

    To create a resource record in a DNS zone:

    Management console
    CLI
    Terraform
    1. In the management console, select the folder containing the DNS zone to create a record in.
    2. Select Cloud DNS.
    3. Select the zone from the list.
    4. Click Create record.
    5. Set the record parameters:
      1. Domain name.
      2. Record type.
      3. Record TTL.
      4. Record value.
    6. 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.

    1. 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.

    2. 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.

    3. To create resources, run the command:

      terraform apply
      
    4. 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.

    Was the article helpful?

    Language / Region
    © 2022 Yandex.Cloud LLC