The problem is that parseYAML returns Go maps where the map keys can be of varying data types, whilst most of the rest of the consul-template functions that work with maps expect to work with Go maps where the keys are restricted to being strings only.
This typing difference is determined statically when the map is being created, so it doesn’t matter whether the keys in the YAML just happen to all be strings - it’s still a type difference that the Go type system will error on.
Ultimately, consul-template is pretty far away from being a complete programming language, so there’s no way to solve this with the built-in functionality of the language today.
I can see two/three options:
Attempt to use consul-template’s plugin support to work around this … I’m not convinced this is a good option since plugin input uses command line parameters - so this would imply passing whole YAML documents in command line parameters … it feels like a quoting mishap or length limitation would mess things up sooner or later. Also the security implications of exposing input to all processes executing on the same OS.
Add a new function to the consul-template project, and build a custom version (and maybe try to get it merged upstream)