pkl icon indicating copy to clipboard operation
pkl copied to clipboard

Terraform examples

Open titanous opened this issue 2 years ago • 12 comments

It'd be great if there were examples of using pkl instead of HCL for Terraform in the same way that there is pkl-k8s-examples.

titanous avatar Feb 05 '24 19:02 titanous

I agree; we'll work on providing something here.

bioball avatar Feb 06 '24 06:02 bioball

Oh yes, for Terraform would be great!

MisterJD avatar Feb 20 '24 23:02 MisterJD

I agree; we'll work on providing something here.

Do you have any ETA, even if a bit farfetched? Or, maybe, you can give this a look and help us in some way while we wait? Any help related to creating Terraform syntax would be appreciated... Thank you

pedrodsrodrigues avatar Mar 12 '24 11:03 pedrodsrodrigues

A part of the problem is that matching common practice would require defining properties for all providers on one level, because HCL just merges the namespaces for everything. That is, if you want the same set of autocompletions on the top level. There are alternative ways to do this, but we want to be a little bit cautious to not dictate The One True Way to replace HCL with Pkl, given these alternatives. We need to construct a few different approaches to demonstrate the variability.

holzensp avatar Mar 12 '24 16:03 holzensp

To be honest, I would like to have a solution for dynamically generating tfvars files with pkl. Currently my way of handling this problem is writing my own shell scripts to inject my own logic and set variables through either the TF_VAR environment parameters or adding them into the tfvars files before executing them on my each environment. One of my dreams would be a way to merge multiple tfvar files in a way one contains the base environment configurations and extend these variables with these dynamic pkl injections. Something like “shared-prod.tfvars” + “customer-x.tfvars”. One problem that occurs here is if multiple files sets the same variable, i would like to merge them if there could be an overwrite option whenever variables are duplicated in the manifest which is not permitted in HCL.

Another use case would be handling the provider version settings with tf files. Currently we are using different versions of the same providers between each terraform configuration. we were using Dhall before to solve this problem and we could dynamically generate these provider and backend tf configuration files but it would be nice to solve these issues here too and then pkl would be a nice option to dhall as well

DorukAkinci avatar Mar 27 '24 16:03 DorukAkinci