mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Terraform examples #33
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @titanous on GitHub (Feb 5, 2024).
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.
@bioball commented on GitHub (Feb 6, 2024):
I agree; we'll work on providing something here.
@MisterJD commented on GitHub (Feb 21, 2024):
Oh yes, for Terraform would be great!
@pedrodsrodrigues commented on GitHub (Mar 12, 2024):
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
@holzensp commented on GitHub (Mar 12, 2024):
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.
@DorukAkinci commented on GitHub (Mar 27, 2024):
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
@KiaraGrouwstra commented on GitHub (Jan 1, 2025):
user-friendly TF support here may involve generating PKL types for TF providers, like
tf-ncldoes for nickel-lang.@tienhuynh5312 commented on GitHub (Jul 29, 2025):
Since Terraform alternatively supports JSON to declare resources. Would JsonRenderer be enough to run Terraform?
https://developer.hashicorp.com/terraform/language/syntax/json
@HT154 commented on GitHub (Jul 29, 2025):
Absolutely!
https://github.com/apple/pkl/issues/912 is another missing piece that would make using Pkl for Terraform a great experience.
@kaihendry commented on GitHub (Sep 15, 2025):
Thanks, inspired to conjure up https://github.com/kaihendry/terraform-config POC on how to leverage PKL to deploy Terraform.
@mikhail-putilov commented on GitHub (Oct 9, 2025):
I tried to generate simple http tests with Terraform in JSON format and couldn't proceed: JSON format has bugs :-)
When I run this, then the test passes:
I had a bunch of such tests. I wanted to generate them from Pkl by generating Terraform in JSON format:
However, this did not work at all:
:-(
is it possible to generate HCL-based tests with Pkl? Can someone point me into the right direction, how to do that? In the mean time, I wrote Pkl-based tests with
read("http://my-api-gateway/"), but it lacks error messages when assertion fails -- not so optimal right now.@mikhail-putilov commented on GitHub (Oct 9, 2025):
Answering my own question:
This is what I did:
Which gives me:
@mikhail-putilov commented on GitHub (Oct 11, 2025):
I played a little with Pkl in order to generate something useful in HCL and came to this:
In order to generate the following test:
I have come up with these abstractions:
I don't know if I should continue or not. I suspect this is the intended way of using Pkl to generate something like HCL. However, it seems like a lot of work to continue writing in this style :-)