I often lack expressiveness when creating Nomad jobs. The HCL2 language is limited in terms of generation and processing, doesn’t allow for features like
reading environment variables , getting results of custom command, dynamic blocks in specific cases. Overall, the syntax is limited to syntactic sugars on top of HCL configuration language.
Lua is a very simple extensible scripting programming language that is easy to embed in existing projects. The recent success of Neovim spawned millions of lines of Lua plugins code. There are two GitHub - Shopify/go-lua: A Lua VM in Go and GitHub - yuin/gopher-lua: GopherLua: VM and compiler for Lua in Go Lua go modules that could be used within Nomad binary.
I made a small test how that would look like and generating Nomad job specification from Lua module looks really nice. It looks promising, and the job generation from Lua is very simple and very much extensible, can use any environment variables and options and loops and anything we programmers might want to use to cook any job specification we want.
While I do not think I will pursue it further, I decided that I will query the community. The alternative is to use an existing preprocessor - jinja2, m4, php, go-templates in Levant. But I think Lua looks nice here and could lower the developer cost that is of introducing new HCL2 features. Is this something that could be potentially considered? What others think about this idea?