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 period. You cannot create public top-level domain (TLD) zones. To create a domain zone with non-Latin characters, use the Punycode
encoding. - Type:
Public
- Name of the zone.
- Zone: Domain zone. The zone name must end with a period. You cannot create public top-level domain (TLD) zones. To create a domain zone with non-Latin characters, use the Punycode
- 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.
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 <zone_name> \ --zone <domain_zone>. \ --public-visibility=true
Where:
--name
: Zone name. It must be unique within the folder. This is an optional parameter.--zone
: Domain zone. The zone name must end with a period. You cannot create public top-level domain (TLD) zones. To create a domain zone with non-Latin characters, use the Punycode encoding. This is a required parameter.--public-visibility
: Flag for creating a public zone.
Result:
id: aet2q4fn8i8i******** folder_id: aoerb349v3h4******** created_at: "2021-03-03T19:07:08.685Z" name: production-zone zone: www.example.com. public_visibility: {}
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the parameters of the resources you want to create:
resource "yandex_dns_zone" "zone1" { name = "<zone_name>" description = "<zone_description>" labels = { label1 = "<zone_label>" } zone = "<domain_zone>." public = true }
Where:
name
: Zone name. It must be unique within the folder. This is an optional parameter.description
: Zone description. This is an optional parameter.labels
: DNS zone labels. This is an optional parameter.zone
: Domain zone. The zone name must end with a period. You cannot create public top-level domain (TLD) zones. To create a domain zone with non-Latin characters, use the Punycode encoding. This is a required parameter.public
: Zone visibility, public or private. This is an optional parameter.
For more information about the
yandex_dns_zone
resource properties, see the provider documentation . -
Create resources:
-
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 get <zone_name>
-
To create a public DNS zone, use the create REST API method for the DnsZone resource or the DnsZoneService/Create gRPC API call.
To get access to public zone domain names, you need to delegate the domain. Specify the addresses of the ns1.yandexcloud.net
and ns2.yandexcloud.net
servers in your account on your registrar's website.