Deleting a resource record
To delete a resource record:
- In the management console
, select the folder containing the DNS zone with the record you want to delete. - Select Cloud DNS.
- Select the zone from the list.
- Find the record you want to delete and click
in its row. - In the menu that opens, click Delete.
- In the window that opens, click Delete.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
See the description of the CLI command for deleting a record:
yc dns zone delete-records --help -
Get a list of all zone records:
yc dns zone list-records --name <zone_name> -
If the record has a description, clear it before deletion:
yc dns zone add-records --name <zone_name> \ --record "<domain_name> <TTL> <record_type> <value>" \ --description "" -
Delete the record:
yc dns zone delete-records --name <zone_name> \ --record "<domain_name> <TTL> <record_type> <value>"
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To delete a DNS resource record created with Terraform, do the following:
-
Open the Terraform configuration file and delete the fragment describing the DNS record.
Terraform DNS record description example
... 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"] description = "Web server" } ... -
In the command line, navigate to the directory with the Terraform configuration file.
-
Check the configuration using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm changes.You can check the updates in the management console
or using this CLI command:yc dns zone list-records <zone_name>
To delete a resource record, use one of the following methods:
-
upsertRecordSets: The move REST API method for the DnsZone resource or the DnsZoneService/UpsertRecordSets gRPC API call. The method does not require an exact match of the
descriptionfield. -
updateRecordSets: The move REST API method for the DnsZone resource or the DnsZoneService/UpdateRecordSets gRPC API call. The method requires an exact match of all the record's fields, including
description.
REST API example for the upsertRecordSets method
Below is an example of a Bash script for Linux.
To use it, get authenticated with the API and install cURL
-
Create a script file:
sudo touch <file_name> -
Open the file to write the script to:
sudo nano <file_name> -
Place the script in the file:
#!/bin/bash # Creating variables export IAM_TOKEN=$(yc iam create-token) dnsZoneId='<DNS_zone_ID>' recordName='<domain_name>' recordType='<record_type>' recordTtl='<TTL>' recordData='<value>' # Deleting a record via upsertRecordSets curl \ --request POST \ --header "Authorization: Bearer ${IAM_TOKEN}" \ --header "Content-Type: application/json" \ --data '{ "deletions": [ { "name": "'"${recordName}"'", "type": "'"${recordType}"'", "ttl": "'"${recordTtl}"'", "data": ["'"${recordData}"'"] } ] }' \ "https://dns.api.cloud.yandex.net/dns/v1/zones/${dnsZoneId}:upsertRecordSets"Where:
IAM_TOKEN: IAM token for API authentication.dnsZoneId: DNS zone ID. To find out the ID, get a list of DNS zones.recordName: Record domain name, e.g.,srv.example.com..recordType: Entry type, e.g.,A.recordTtl: Record lifetime (TTL) in seconds, e.g.,600.recordData: Record value, e.g.,10.1.0.1.
Tip
To use the
updateRecordSetsmethod, replaceupsertRecordSetsin the URL withupdateRecordSets. Note that in this case, all the record's fields, includingdescription, must match exactly. -
Make the file executable:
chmod +x <file_name> -
Run the script:
./<file_name>
This will return an operation in JSON format:
{
"id": "dns1234567890abcdef",
"description": "",
"createdAt": "2025-01-15T12:00:00.000000000Z",
"createdBy": "aje1234567890abcdef",
"modifiedAt": "2025-01-15T12:00:00.000000000Z",
"done": true,
"metadata": {},
"response": {
"@type": "type.googleapis.com/yandex.cloud.dns.v1.RecordSetDiff",
"additions": [],
"deletions": [
{
"name": "srv.example.com.",
"type": "A",
"ttl": "600",
"data": ["10.1.0.1"]
}
]
}
}
Where:
id: Unique operation ID.done: Operation completion status.response.deletions: List of deleted records.
gRPC API example for the upsertRecordSets method
Below is an example Bash script for calling the gRPC API using grpcurl.
-
Install
grpcurl:-
Using Bash:
curl -L https://github.com/fullstorydev/grpcurl/releases/download/v1.9.3/grpcurl_1.9.3_linux_x86_64.tar.gz | tar -xz sudo mv grpcurl /usr/local/bin/ -
Using Golang:
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
-
-
Create a script file:
sudo touch <file_name> -
Open the file to write the script to:
nano <file_name> -
Place the script in the file:
#!/bin/bash # Creating variables export IAM_TOKEN=$(yc iam create-token) dnsZoneId='<DNS_zone_ID>' recordName='<domain_name>' recordType='<record_type>' recordTtl='<TTL>' recordData='<value>' # Deleting a record via UpsertRecordSets grpcurl \ -d "{ \"dns_zone_id\": \"${dnsZoneId}\", \"deletions\": [ { \"name\": \"${recordName}\", \"type\": \"${recordType}\", \"ttl\": \"${recordTtl}\", \"data\": [\"${recordData}\"] } ] }" \ -H "authorization: Bearer ${IAM_TOKEN}" \ -H "x-client-request-id: $(uuidgen)" \ dns.api.cloud.yandex.net:443 \ yandex.cloud.dns.v1.DnsZoneService/UpsertRecordSetsWhere:
IAM_TOKEN: IAM token for API authentication.dnsZoneId: DNS zone ID. To find out the ID, get a list of DNS zones.recordName: Record domain name, e.g.,srv.example.com..recordType: Entry type, e.g.,A.recordTtl: Record lifetime (TTL) in seconds, e.g.,600.recordData: Record value, e.g.,10.1.0.1.x-client-request-id: Unique request ID for tracing.
Tip
To use the
UpdateRecordSetsmethod, replaceUpsertRecordSetsin the script withUpdateRecordSets. Note that in this case, all the record's fields, includingdescription, must match exactly. -
Make the file executable:
chmod +x <file_name> -
Run the script:
./<file_name>
This will return an operation in JSON format:
{
"id": "dns1234567890abcdef",
"description": "",
"createdAt": "2025-01-15T12:00:00.000000000Z",
"createdBy": "aje1234567890abcdef",
"modifiedAt": "2025-01-15T12:00:00.000000000Z",
"done": true,
"metadata": {
"@type": "type.googleapis.com/yandex.cloud.dns.v1.UpsertRecordSetsMetadata"
},
"response": {
"@type": "type.googleapis.com/yandex.cloud.dns.v1.RecordSetDiff",
"additions": [],
"deletions": [
{
"name": "srv.example.com.",
"type": "A",
"ttl": "600",
"data": ["10.1.0.1"]
}
]
}
}
Where:
id: Unique operation ID.done: Operation completion status.metadata: Operation metadata.response.deletions: List of deleted records.
For a detailed method description, see the gRPC API reference.