Creating a public DNS zone
To create a public DNS zone:
- In the management console, select the folder where you need to create a DNS zone.
- Select Cloud DNS.
- Click Create zone.
- Specify the zone settings:
- Zone: Domain zone. The zone name must end with a dot. You can't create public top-level domain (TLD) zones.
- Type: Public.
- Zone name.
- 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.
To create a new DNS zone:
-
View a description of the CLI create zone command:
yc dns zone create --help
-
Create a new public DNS zone in the default folder:
yc dns zone create --name production-zone --zone www.example.com. --public-visibility
Command output:
id: aet2q4fn8i8icfug97p0 folder_id: aoerb349v3h4bupphtaf created_at: "2021-03-03T19:07:08.685Z" name: production-zone zone: www.example.com. public_visibility: {}
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:
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.
DNS record 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-public-zone" description = "Test public zone" labels = { label1 = "test-public" } zone = "test.example-public2.com." public = true } resource "yandex_dns_recordset" "rs1" { zone_id = yandex_dns_zone.zone1.id name = "test.example-public.com." type = "A" ttl = 200 data = ["10.1.0.1"] }
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 get <DNS zone name>
To get access to public zone domain names, you need to delegate the domain. Specify the addresses of the ns1.yandexcloud.net
and the ns2.yandexcloud.net
servers in your user area on your registrar's site.