Added support for new Hetzner Cloud Api#852
Conversation
|
Is there a way to fast-track this PR? I can't migrate my zones because this PR is not part of a released version. |
Same here. I would really appreciate a fast release of this new feature! |
| debug("creating DNS '$type'"); | ||
| $url = "https://" . opt('server', $domain) . "/zones/$zone/rrsets"; | ||
| $http_method = "POST"; | ||
| $data = "{\"name\":\"$hostname\",\"type\":\"$type\",\"ttl\":" . opt('ttl', $domain) . ",\"records\":[{\"value\":\"$ip\",\"comment\":\"Created by ddclient\"}],\"labels\":{\"environment\":\"prod\",\"example.com/my\":\"label\"}}"; |
There was a problem hiding this comment.
I guess you don't want to put labels on every rrset (like this) :) Would maybe a good idea to drop them if they are not needed. Or maybe put the created by into a label and let the users still be able to change the comment on each individual record.
|
@lecram89 Can you fix what the reviewer pointed out? |
|
If I understand the documentation https://docs.hetzner.cloud/reference/cloud#zone-rrsets-create-an-rrset correctly then it's not needed. For this point of view: {
"name": "www",
"type": "A",
"ttl": 3600,
"records": [
{
"value": "198.51.100.1",
"comment": "My web server at Hetzner Cloud."
}
],
"labels": {
"environment": "prod",
"example.com/my": "label",
"just-a-key": ""
}
}only these keys are mandatory: So this should be enough: {
"name": "www",
"type": "A",
"records": [
{
"value": "198.51.100.1"
}
]
}So doing this on the $data value: $data = "{\"name\":\"$hostname\",\"type\":\"$type\",\"ttl\":" . opt('ttl', $domain) . ",\"records\":[{\"value\":\"$ip\"}]}";But wouldn't it also make sense to apostrophe the part - so sth. like this? $data = '{"name":"$hostname","type":"$type","ttl":' . opt('ttl', "$domain") . ',"records":[{"value":"$ip"}]}"; |
|
I tried using this PR's implementation and encountered 404 errors. After investigating, I found the issue: The current implementation uses an incorrect API endpoint structure: my $url = "https://" . opt('server', $domain) . "/zones/$zone/rrsets/$hostname/$type";This uses the zone name directly in the URL path ( According to the Hetzner Cloud API documentation, the correct flow is:
The fix mirrors the existing
Key changes needed: # 1. First get the zone ID
my $url = "https://$config{$key}{'server'}/zones?name=" . $config{$key}{'zone'};
# ... fetch and parse to get $zone_id ...
# 2. Get records using zone ID
$url = "https://$config{$key}{'server'}/zones/$zone_id/records";
# 3. Update or create using zone ID
if ($dns_rec_id) {
$url = "https://$config{$key}{'server'}/zones/$zone_id/records/$dns_rec_id";
$http_method = "PUT";
} else {
$url = "https://$config{$key}{'server'}/zones/$zone_id/records";
$http_method = "POST";
}
my $data = "{\"zone_id\":\"$zone_id\", \"name\": \"$hostname\", \"value\": \"$ip\", \"type\": \"$type\", \"ttl\": $config{$key}{'ttl'}}";This PR targets |
@erahhal using the zone name is totally fine: https://docs.hetzner.cloud/reference/cloud#zone-rrsets-list-rrsets |
|
Hi Guys, |
This also works: |
|
Anything I can support to get this merged? Hetzner will shutdown the old approach till end May 2026 |
|
I just gave this a try by overriding the NixOS package and one thing I noticed is that this introduces |
|
Since there have been no updates for a while, I addressed all the concerns in this conversation here so that we can merge these changes before end of May.
|
True. Currently integrate this branch. Adding ps.JSON to myperl is enough. It build ans runs. But, one observation is that the behavior changed. Previously If records (e.g. A/AAAA) were not available, these were created with the IP/IPv6 addresses Have not done a deep dive, but will. Someone else can confirm? |
|
Just to line this out, the old DNS API will be turned off at 20. May 09:00 UTC. As of this, the currently running brownouts will be permanent and also cover Read Endpoints soon after. The automatic migration is already running, so expect to have the zones migrated at latest at the beginning of May. (Zones with active API tokes, like the ones ddclient use, will be the last zones on the list) |
Added support for the new Cloud DNS Api from Hetzner:
https://docs.hetzner.cloud/reference/cloud#overview