NixOS / nixops-aws

GNU Lesser General Public License v3.0
52 stars 37 forks source link

question: autogenerated route 53 private entries #53

Open coretemp opened 6 years ago

coretemp commented 6 years ago

@rbvermaa

  machine_foo = <elided>;

   resources.route53RecordSets = {

        a-record = { resources, ... }: {
          recordValues = [ <expression>];
          zoneId = "Z...";
          domainName = "www.example.com.";
          recordType = "A";
    };
    };

What do I need if I want to refer to the private IPv4 address of machine_foo? The other Route53 feature in NixOps only allows using the public IP.

The problem is that I cannot just put in a number, because the private IP is assigned by AWS.

betaboon commented 6 years ago

according to https://github.com/NixOS/nixops/blob/master/nix/route53-recordset.nix#L84 you can do recordValues = [ resources.machines.machine_foo ]; (which is how i do it)

but as you asked specifically for the private IPv4: according to https://github.com/NixOS/nixops/blob/master/nixops/resources/route53_recordset.py#L154 passing in a machine definition leads to usage of the publicIPv4 only and there doesnt seem to be a way to use the privateIPv4.

maybe this option is what you are looking for: https://nixos.org/nixops/manual/#opt-deployment.route53.usePublicDNSName

you could always do resources.machines.machine_foo.networking.privateIPv4 but i don't know what public opinion says about this.

coretemp commented 6 years ago

@betaboon Your suggestion ("you could always do") fails with The option networking.privateIPv4 is used but not defined..

betaboon commented 6 years ago

@coretemp that should only happen during --build-only etc as it references the privateIPv4 of the deployed machine. Which prior do being created does not exist. That's the downside of that approach.

coretemp commented 6 years ago

@betaboon Thanks for you reply. As you can see, I am not passing --build-only:

nixops deploy -s localstate.nixops --kill-obsolete -d foo --allow-reboot --show-trace

betaboon commented 6 years ago

@coretemp could you share the expression of the machine and the route53RecordSet ?

coretemp commented 6 years ago

Any description of my_machine would do (I expect even an empty one), so just pick the one from the NixOps manual or one of your own.

I think the easiest repro would be just trying to add an expression similar to the one below to one of your existing machines. It will return the same.

   resources.route53RecordSets = {
      a-record = { resources, nodes,  ... }: {
          zoneId = "ZSOME_VALID_ID";
          domainName = ''www.example.com.'';
          ttl = 300;
          recordValues = [ (builtins.trace (resources.machines.my_machine.networking.privateIPv4) "1.1.1.1")];
          recordType = "A";
      };
  };

This shouldn't even set the privateIP, it should merely print the value, but even that doesn't work.

betaboon commented 6 years ago

@coretemp what version of nixops are you running?

coretemp commented 6 years ago

master

betaboon commented 6 years ago

@coretemp i just tried that way. can confirm that it doesn't work. which is kind of confusing to me, as i use references to networking.privateIPv4 in different locations like that.

lo1tuma commented 6 years ago

I’ve run into the same issue. Does someone already know how this could be achieved?

tomberek commented 5 years ago

Would this help? https://github.com/NixOS/nixops/pull/1054

JosephLucas commented 3 years ago

On this issue, in addition to resources.machines.my_machine.networking.privateIPv4, I also tried nodes.<ecc-name>.config.networking.privateIPv4 without any success. Any help ?

exFalso commented 3 years ago

Confirm, config.networking.privateIPv4 does not work. Tried with both the passed in config and nodes.<machine>.config