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

Multiple persistent elastic IPs

Open memberbetty opened this issue 5 years ago • 2 comments

Currently, the following single IP declaration is supported.

deployment.ec2.elasticIPv4 = mkOption {
  default = "";
  example = "123.1.123.123";
  type = types.either types.str (resource "elastic-ip");
  apply = x: if builtins.isString x then x else "res-" + x._name;
  description = ''
    Elastic IPv4 address to be associated with this machine.
  '';
};

I'd like to have a feature where we can define multiple, which are not ever released (as in returned to the AWS pool).

Example of the desired configuration option:

deployment.ec2.elasticIPv4s = ["1.2.3.4" "2.3.4.5"]

In this context it can be assumed that 1.2.3.4 and 2.3.4.5 are allocated elastic IP addresses, but possibly not associated.

memberbetty avatar Jun 01 '19 07:06 memberbetty

Hi, you can use the elasticIp resource for that

resources.elasticIPs.eip1 =
    {
      region = region;
      accessKeyId = accessKeyId;
      vpc = true;
    }
resources.elasticIPs.eip2 =
    {
      region = region;
      accessKeyId = accessKeyId;
      vpc = true;
    };
.....

then if you want to allocate a given eip to a machine just use this

deployment.ec2.elasticIPv4s = resources.elasticIPs.eip1

Hope this is what you was asking for.

PsyanticY avatar Jun 01 '19 12:06 PsyanticY

No, I want to bind multiple (already existing) elastic IPs to the same machine.

In your example, you are still only binding a single elastic IP to a single machine.

memberbetty avatar Jun 03 '19 13:06 memberbetty