nixops-aws icon indicating copy to clipboard operation
nixops-aws copied to clipboard

Cannot host ec2 instance on root domain

Open justinlovinger opened this issue 5 years ago • 1 comments

Given deployment.route53.hostName = domain-name.root, running nixops deploy gives error "Exception: hosted zone for com not found".

The full exception is

webserver..> sending Route53 DNS: example.com A 18.218.14.24
Traceback (most recent call last):
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/bin/..nixops-wrapped-wrapped", line 991, in <module>
    args.op()
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/bin/..nixops-wrapped-wrapped", line 412, in op_deploy
    max_concurrent_activate=args.max_concurrent_activate)
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1063, in deploy
    self.run_with_notify('deploy', lambda: self._deploy(**kwargs))
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1052, in run_with_notify
    f()
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1063, in <lambda>
    self.run_with_notify('deploy', lambda: self._deploy(**kwargs))
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 996, in _deploy
    nixops.parallel.run_tasks(nr_workers=-1, tasks=self.active_resources.itervalues(), worker_fun=worker)
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/lib/python2.7/site-packages/nixops/parallel.py", line 44, in thread_fun
    result_queue.put((worker_fun(t), None, t.name))
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 969, in worker
    r.create(self.definitions[r.name], check=check, allow_reboot=allow_reboot, allow_recreate=allow_recreate)
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/lib/python2.7/site-packages/nixops/backends/ec2.py", line 1101, in create
    self._update_route53(defn)
  File "/nix/store/33qlsqvq92v7ny8p9af1zsvmxki5jd74-nixops-1.7/lib/python2.7/site-packages/nixops/backends/ec2.py", line 1273, in _update_route53
    raise Exception('hosted zone for {0} not found'.format(hosted_zone))
Exception: hosted zone for com not found

justinlovinger avatar Mar 07 '20 18:03 justinlovinger

I think I found the relevant line of code. The hosted zone is obtained by stripping the first part of the DNS host name, but if the DNS host name is the hosted zone itself, then it doesn't match.

Is there any reason to strip the first part of the host name? It looks like the code already checks a subset of the host name parts when matching against a hosted zone. All that stripping the first part of the host name does is ensure you don't add a record to a hosted zone that exactly matches the host name, but I'm not sure why that would be desirable.

If I had to guess, I'd say that line probably could have changed when this commit was made.

justinlovinger avatar Mar 07 '20 22:03 justinlovinger