Closed Xarthisius closed 6 years ago
I generated the key/secret via https://developer.godaddy.com/keys, but when I run terraform (or access the API directly via curl, I get an error Domain ... not found for shopper
:
* godaddy_domain_record.create_dns_dns: couldn't find domain (wholetale.org): [404:NOT_FOUND] Domain wholetale.org not found for shopper
$ curl -X GET https://api.godaddy.com/v1/domains/wholetale.org \
-H "Authorization: sso-key ${GODADDY_API_KEY}:${GODADDY_API_SECRET}"
{"code":"NOT_FOUND","message":"Domain wholetale.org not found for shopper","name":"ApiError"}
I've tried setting the customer
value to my customer ID, but to no avail. Next step is to see if an official Key/Secret created by Bertram's account will work.
@xarthisius As discussed, the terraform plugin supports only the PUT method for /records, which requires providing the complete DNS configuration (i.e., all DNS entries and nameservers, etc), which is obviously undesirable.
There is a PATCH method to create a single A record:
curl -s -X PATCH https://api.godaddy.com/v1/domains/<domain>/records
-H "Authorization: sso-key ${godaddy_key}:${godaddy_secret}"
-H "accept: application/json" -H "Content-Type: application/json"
-d "[ { \"data\": \"${ip_address}\", \"name\": \"*.${subdomain}\", \"ttl\": 3600, \"type\": \"A\" }]
And a PUT method on /records/type/name:
curl -s -X PUT https://api.godaddy.com/v1/domains/<domain>/records/A/*.${subdomain}
-H "Authorization: sso-key ${godaddy_key}:${godaddy_secret}"
-H "accept: application/json"
-H "Content-Type: application/json" -d "[ { \"data\": \"${ip_address}\", \"name\": \"*.${subdomain}\", \"ttl\": 3600, \"type\": \"A\" }]
These both work fine outside of Terraform. So the question is where to go from here. A few options -- all require remote-exec
Any preferences?
When faced with choosing programming language dilemma I'm gonna always choose Python ;)
However, in this case I'm not sure that pygodaddy is good enough... It doesn't look like it supports api tokens, only user/pass. Wrapping those HTTP reqs with just requests
package shouldn't be difficult though.
So be it. Anything I can do with curl
I can do with requests
. I was initially envisioning needing to create an image for this, but I expect that something this simple can use the official python image.
We could use https://github.com/n3integration/terraform-godaddy to set up DNS records as a part of deployment script.