pan-net / terraform-provider-powerdns

Terraform PowerDNS provider
https://www.terraform.io/docs/providers/powerdns/
Mozilla Public License 2.0
44 stars 48 forks source link

Add support for LUA records (Feature Request) #65

Open WhatshallIbreaktoday opened 3 years ago

WhatshallIbreaktoday commented 3 years ago

First, thanks for your great work! Please find a new feature Request regarding Powerdns LUA Records.

Affected Resource(s)

Expected Behavior

To be able to pass LUA Records to Powerdns. https://doc.powerdns.com/authoritative/lua-records/. I do not expect the provider to handle the LUA syntax, but just to pass LUA Record to Powerdns API. (Let Powerdns handle issues with LUA syntax..)

mbag commented 3 years ago

@WhatshallIbreaktoday do you have working API example? I couldn't find anything in the PowerDNS API documentation: https://doc.powerdns.com/authoritative/http-api/index.html

I found someone mentioned that they were able to figure out API syntax and opened issue to document it (https://github.com/PowerDNS/pdns/issues/9310) but it seems no one added the documentation.

If you send me working API example (curl example would be the best), I can implement it. But since there are no checks on record type, I think that LUA type would be supported, same as A or NS or any other type.

mbag commented 3 years ago

@WhatshallIbreaktoday ok, never mind, I managed to figure out the API syntax.

So it seems that this works out of the box without need to change the code. Here is the syntax (tested against docker-compose pdns server that I have for testing in this repo, after setting --enable-lua-records=yes in docker-compose.yml):

  zone = "sysa.xyz."
  name = "test-lua.sysa.xyz."
  type = "LUA"
  ttl = 60
  records = [ "A \"pickrandom({'192.168.0.111','192.168.0.222'})\"" ]
}

I don't know what LUA functions are you using, but you might need to play around with quotes and escaping them, to be able to send correct syntax to PowerDNS server.

I'll add this to documentation, however it might take some time, as I still haven't migrated to new documentation strucutre needed by Terraform Registry.

Thanks for raising this issue.