Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

115 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HXL


CI Hex.pm Version

An Elixir implementation of HCL

Features

  • Decode from string or file
  • Aims to be fully compliant with the HCL specification
  • Function & variables support during evaluation

Example Usage

hcl = """
resource "upcloud_server" "server1" {
  hostname = "terraform.example.com"

  zone = "nl-ams1"

  plan = "1xCPU-1GB"

  template {
    size = 25
    storage = "01000000-0000-4000-8000-000030200200"
  }

  network_interface {
    type = "public"
  }

  login {
    user = "root"
    keys = [
      "ssh-rsa public key",
    ]
    create_password = true
    password_delivery = "email"
  }

  connection {
    host        = "127.0.0.2"
    type        = "ssh"
    user        = "root"
    private_key = file("~/.ssh/rsa_private_key")
  }

  provisioner "remote-exec" {
    inline = [
      "echo 'Hello world!'"
    ]
  }
}
"""

{:ok, config_file} = HXL.decode(hcl, functions: %{"file" => &File.read/1})

From file

{:ok, config_file} = HXL.decode_file("/path/to/file")

As ast

hcl = """
service "http" {
  a = 1
  b = 2
}
"""

{:ok, %HXL.Body{}} = HXL.decode_as_ast(hcl)

Installation

Add hxl to your list of dependencies in mix.exs:

def deps do
  [
    {:hxl, "~> 0.1.0"}
  ]
end

HCL Syntax Specification

  • Comments
  • Identifiers
  • Operators & delimiters
  • Numeric literals
  • Body
  • Attributes
  • Blocks
  • One-line blocks
  • Expressions
    • Expr term
      • Literal Value
      • Collection Value
      • Template Expr
      • Variable Expr
      • Function Call
      • For Expr
      • ExprTerm Index
      • ExprTerm GetAttr
      • ExprTerm Splat
      • "(" Expression ")"
    • Operation
    • Conditional
  • [] TemplateLiteral
  • [] TemplateInterpolation
  • [] TemplateDirective

Representations

  • HCL Native syntax
  • JSON

About

An Elixir implementation of HCL.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages