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

question: autogenerated route 53 private entries

Open coretemp opened this issue 6 years ago • 13 comments

@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.

coretemp avatar Jul 26 '18 10:07 coretemp

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.

betaboon avatar Jul 30 '18 08:07 betaboon

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

coretemp avatar Aug 01 '18 10:08 coretemp

@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.

betaboon avatar Aug 01 '18 10:08 betaboon

@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

coretemp avatar Aug 01 '18 11:08 coretemp

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

betaboon avatar Aug 06 '18 18:08 betaboon

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.

coretemp avatar Aug 07 '18 08:08 coretemp

@coretemp what version of nixops are you running?

betaboon avatar Aug 07 '18 09:08 betaboon

master

coretemp avatar Aug 07 '18 09:08 coretemp

@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.

betaboon avatar Aug 07 '18 10:08 betaboon

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

lo1tuma avatar Sep 26 '18 17:09 lo1tuma

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

tomberek avatar Jul 05 '19 20:07 tomberek

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 ?

JosephLucas avatar Oct 20 '20 14:10 JosephLucas

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

exFalso avatar Dec 11 '20 11:12 exFalso