3 ms·
This is not code. This is configuration. FWIW we've been working on letting you declare data in YSH, a new Unix shell. So you can arbitrarily interleave code
by chubot 2y ago
This is not code. This is configuration.
FWIW we've been working on letting you declare data in YSH, a new Unix shell.
So you can arbitrarily interleave code and data, with the same syntax. The config dialect is called "Hay" - Hay Ain't YAML.
Here's a demo based on this example: https://github.com/oils-for-unix/blog-code/blob/main/hay/iac-demo.ysh https://github.com/oils-for-unix/blog-code/blob/main/hay/iac...
It looks almost the same as HCL (although I think this was convergent evolution, since I've actually never used Terraform):
# this is YSH code!
echo 'hello world'
Data aws_route53_zone cetacean_club {
name = 'cetacean.club.'
}
Resource aws_route53_record A {
zone_id = data.aws_route53_zone.cetacean_club.zone_id
name = "ingressd.$[data.aws_route53_zone.cetacean_club.name]"
type = 'A'
ttl = "300"
}
And then the stdout of this config "program" is here - https://github.com/oils-for-unix/blog-code/blob/main/hay/output.txt https://github.com/oils-for-unix/blog-code/blob/main/hay/out...
It can be serialized to JSON, or post-processed and then serialized
---
Then I show you can wrap Resource in a for loop, as well as parameterize it with a "proc" (procedure).
make-resource (12)
make-resource (34)
if (true) {
make-resource (500)
}
This is all still in progress, and can use feedback, e.g. on Github. (This demo runs, but it relies on a recent bug fix.)
The idea is not really to make something like Terraform, but rather to make a language with metaprogramming powerful enough to make your own "dialects", like Terraform.
---
I wrote a doc about Hay almost 3 years ago - Hay - Custom Languages for Unix Systems - https://oils.pub/release/0.27.0/doc/hay.html https://oils.pub/release/0.27.0/doc/hay.html
Comments - https://lobste.rs/s/phqsxk/hay_ain_t_yaml_custom_languages_for_unix https://lobste.rs/s/phqsxk/hay_ain_t_yaml_custom_languages_f...
At that time, Oils was a slow Python prototype, but now it's fast C++! So it's getting there
The idea of Oils is shell+Python+JSON+YAML, squished together in the same language. So this works by reflection and function calls, not generating text ("Unix sludge"). No Go templates generating YAML, etc.
- esafak 2y agoWhere is YSH? Is it built into the oil shell? The YSH link in https://www.oilshell.org/cross-ref.html#YSH https://www.oilshell.org/cross-ref.html#YSH is broken.
- chubot 2y agoYes sorry, if you install the latest oils-for-unix binary - https://oils.pub/release/latest/ https://oils.pub/release/latest/ - Then you will get a symlink called "ysh". It's also available in a few distros, HomeBrew, etc. As mentioned, the demo depends on a bug fix that hasn't been released yet. Right now there are a bunch of people on Zulip giving feedback, so you are welcome to join and ask questions / give feedback, or wait until it's more fully baked YSH itself is pretty "baked", but the Hay part is in flux --- I fixed the link, thank you for mentioning that! https://www.oilshell.org/cross-ref.html?tag=YSH#YSH https://www.oilshell.org/cross-ref.html?tag=YSH#YSH