Initialize Nerves system from EC2 metadata
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This module initializes a Nerves system using Amazon EC2 metadata. It is similar to nerves_init_gadget, but specialized for Amazon EC2.

An example app that uses it is hello_nerves_ec2.

It does the following:

  • Brings up networking

  • Starts an IEx console acccessible via ssh using the key pair specified for the instance

  • Configures the node name and starts distributed Erlang net_kernel

  • Logging via ring_logger


Add nerves_init_ec2 to the deps in your project's mix.exs:

  defp deps(target) do
      {:nerves_runtime, "~> 0.4"},
      {:nerves_init_ec2, github: "cogini/nerves_init_ec2"}
    ] ++ system(target)

Add nerves_init_ec2 to the list of applications to always start in config/config.exs:

config :shoehorn,
  init: [:nerves_runtime, :nerves_init_ec2],
  app: Mix.Project.config()[:app]

Configure nerves_init_ec2. The defaults will bring up a system with an IEx console accessible via ssh on port 22.

config :nerves_init_ec2,
  net_kernel: false,
  node_name: "nerves",
  node_name_public: false,
  ssh_console_port: 22,
  ssh_authorized_keys: [
  #!(Path.join(System.user_home!, ".ssh/authorized_keys"))

ssh_authorized_keys defines static keys. nerves_init_ec2 adds the instance key pair to this list.

If you set net_kernel: true, then nerves_init_ec2 will start up distributed Erlang. The Node name will be node_name@ip. node_name_public: false uses the private IP of the instance, node_name_public: true uses the public IP.