Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/question: generic yaml -> hcl2 converter? #74

Open
schollii opened this issue Nov 19, 2020 · 4 comments
Open

Enhancement/question: generic yaml -> hcl2 converter? #74

schollii opened this issue Nov 19, 2020 · 4 comments

Comments

@schollii
Copy link

Any chance k2tf could just be a generic yaml to hcl2 converter? Perhaps a mode flag which causes it to load yaml and just spit out the equivalent HCL2 syntax to stdout.

@sl1pm4t
Copy link
Owner

sl1pm4t commented Nov 19, 2020

Hi @schollii - at the moment the tool doesn't really read the YAML directly, it uses Kubernetes libraries to parse the YAML into Kubernetes resource objects, and then converts these to HCL. So, supporting YAML to HCL2 would possibly be a bigger change than it might seem.
I like the idea though, so I'll keep it in mind if I come back to doing any significant changes to this tool.

@redeux
Copy link

redeux commented Nov 30, 2020

I believe you can do this with the Terraform yamldecode function.

@schollii
Copy link
Author

The disadvantage of yamldecode (which is very useful for some tasks) is that terraform cannot validate your code. Eg if I have a config.yaml that I use instead of terraform.tfvars, code completion is not available on the values in config.yaml. Luckily terraform can load tfvars in json format which is easy to generate from Python.

@DanTulovsky
Copy link

I believe that https://github.com/jrhouston/tfk8s will do what you want. Caveat is it produces output that works with the https://github.com/hashicorp/terraform-provider-kubernetes-alpha provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants