# Peerage EC2 Provider

![Peerage]( helps your nodes find each other.

It supports DNS-based discovery, which means you can use it out of the box with Kubernetes (and probably also Weave, discoverd, Swarm, or other anything else with dns-based service discovery).

It also supports UDP-based discovery, so that nodes on the same network (like docker containers on the same host) can find each other.

This library adds support for API-based discovery of nodes running in an AWS VPC on EC2 or Elastic Beanstalk.

## Installation

Add `peerage` and `peerage_ec2` to your list of dependencies in mix.exs, and start its application:

    def application do
      [applications: [:peerage]]

    def deps do
      	{:peerage, "~> 1.0.2"},
      	{:peerage_ec2, "~> 1.0.0"},

Note that the latest hex versions may be higher than what is listed here. You can find the latest version on hex for [peerage]( and [peerage_ec2]( You should match the version or alternatively you can use a looser version constraint like `"~> 1.0"`.

## Usage

See ![Peerage]( for setup instructions specific to that library. To configure the `Peerage.Via.Ec2` provider:

   config :peerage, via: Peerage.Via.Ec2, aws_access_key_id: "...",
                                          aws_secret_access_key: "...",
                                          tags: [{:cluster, "..."}, {:service, "..."}]

`tags` are mappings to tags set on your EC2 instances. If using Elastic Beanstalk, these tags are set within the EB environment configuration. The cluster tag is used to discover all nodes in your cluster ("production", "staging", etc). The service tag is used to name each node/service that is found ("accounts", "payments", etc).

`Peerage.Via.Ec2` uses a polling mechanism, so a GenServer is not necessary.