Code as infrastructure with Elixir
"Infrastructure as code" is a misnomer.
We should call it "infrastructure as configuration" or "infrastructure as data" because YAML (Ansible/CloudFormation) and glorified JSON (Terraform) are not code.
Just as functional languages enable us to treat code as data, I believe they give us the ability to treat code as infrastructure.
Crucible is going to explore this idea.
- Declarative and idempotent
- Granular control of create/delete/rollback behavior
- Rollbacks as a first class citizen
- Testing as a first class citizen
- Does not track state outside of execution
defmodule My.Vpc do
@moduledoc """
Some thoughts on what the end goal could look like.
"""
use Crucible.DSL
vpc(:my_vpc) do
subnet :my_subnet_1, cidr: "10.0.3.0/24" do
vm :jenkins do
end
vm :foobar do
end
end
subnet :my_subnet_2, cidr: "10.0.4.0/24" do
on_create fn x -> do_something(x) end
end
end
end
If available in Hex, the package can be installed
by adding crucible
to your list of dependencies in mix.exs
:
def deps do
[
{:crucible, "~> 0.0.1"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/crucible.
- Fork the project
- Make change(s) on a feature branch of your fork
- Run
docker build .
to validate formatting, style, and tests - Submit a PR