3

Adding a DNS record with gcloud is all good

gcloud dns record-sets transaction start -z my-zone
gcloud dns record-sets transaction add -z my-zone --name "some_domain.com" --ttl 0 --type TXT "test"
gcloud dns record-sets transaction execute -z my-zone

But when I try to remove that entry

gcloud dns record-sets transaction start -z my-zone
gcloud dns record-sets transaction remove -z my-zone --name "some_domain.com" --ttl 300 --type TXT "test"
gcloud dns record-sets transaction execute -z my-zone

I always get this error

ERROR: (gcloud.dns.record-sets.transaction.remove) Invalid value for 'parameters.name': 'some_domain.com' (code: 400)

1 Answer 1

10

The DNS zone file standard requires complete domain names to end with a trailing '.' character. Since this is a common mistake, other gcloud dns ... commands automatically append a trailing '.' to domain names if the user forgets to add one. However, this particular command does not seem to be doing that. This will be fixed soon.

Meanwhile, to workaround it, you need to add a trailing '.' in the domain name. So:

gcloud dns record-sets transaction remove -z my-zone --name "some_domain.com." --ttl 300 --type TXT "test"

Alternatively, you can use import/export as follows:

gcloud dns record-sets export -z my-zone RECORDS-FILE

Edit RECORDS-FILE to remove the records you do not need. Then:

gcloud dns record-sets import -z my-zone --delete-all-existing RECORDS-FILE

If you want to clear all records you have created, leaving the NS and SOA records intact, you can /dev/null as import file:

gcloud dns record-sets import -z my-zone --delete-all-existing /dev/null
0

Your Answer

By clicking โ€œPost Your Answerโ€, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.