Podcast about DevSecOps

#52 - Lingon a.k.a Juliens and Jacobs open source project

Lingon puts Terraform state and Kubernetes manifests into Go variables so deployment steps can share values.

16 min read

This time we got to talk about Lingon, an open-source project developed by Julian and Jacob who is a frequent podcast guest. Discover the motivations behind Lingon’s creation and how it bridges the gap between Terraform and Kubernetes. Learn how Lingon simplifies infrastructure management, tackles frustrations with YAML and HCL, and offers greater control and automation.

Discuss the episode or ask us anything on LinkedIn


The glue between your cluster and your cloud is a shell script

Picture a Kubernetes platform split across two directories. One holds the HCL that builds the thing: the VPC, the EKS control plane, the load balancer for ingress, the IAM roles. The other holds the YAML that runs on it: deployments, services, a service account that needs the ARN of a role the first directory created. Terraform knows that value. The manifest needs it. Between them sits a shell script with jq and yq in it, a CI step that writes a file, or a person copying a string into a pull request.

That seam is the part no single tool owns. Leave the script untested and nothing checks it before it runs: a renamed Terraform output surfaces as a failed apply rather than a failed test, and working out which link in the chain produced the error asks you to know all of them. It also sets a ceiling on what you automate. When a value from one side has to decide something on the other, the work can stay a checklist someone follows by hand. Take a snapshot, create the new database, restore into it, point the application at it, verify. Do that enough times and the pattern is obvious, and the checklist is still a document rather than a program.

Lingon is one answer to that seam. It is an Apache-2.0 Go library written for the platforms Julien Bisconti works on at Volvo Cars, with Jacob Lärfors, co-founder of the Nordic consultancy Verifa and a repeat guest on this show. The name is the Swedish word for lingonberry. The readme is blunt about the scope: “Lingon is not a platform, it is a thin wrapper around terraform and kubernetes API in a library”, and its only dependencies are Go, the Terraform CLI and kubectl. The estimate of the audience given on the show is 0.01% of developers. The argument underneath it travels further than the library does.

One more YAML tool is what makes it worse

Start with why anyone would write this in the first place. The complaint is not that Helm is bad or that Kustomize is bad.

Why does adding another YAML tool make debugging harder?

Because the tools are fine on their own and the pain is in the seams between them, which no tool owns. The setups that hurt are the combinations: Helm with Kustomize with Flux with Argo, and then somebody writes a Bash script in the middle that patches a value, and then there’s a jq here and a yq there. Death by a thousand cuts. Each cut is defensible. The sum is a pipeline nobody can hold in their head.

The frustration isn’t a missing language feature either. You want to replace a string in a file, or combine two files, and suddenly you need another tool. Your laptop has one version of Kustomize, production has another, the pipeline has a third, and the feature you leaned on behaves differently in each. When it breaks, the error arrives several layers of overlay away from the line you changed. Lingon’s own comparison notes five layers of overrides in the wild, where finding the right place to make a change “feels like changing the data on disk with a magnetic needle and steady hands”.

HCL draws the complaint from the other end, and not for want of editor tooling: HashiCorp’s VS Code extension has done completion for resources and attributes from provider schemas since June 2020. The parts that hurt are the ones no editor sees. How you split state has to be close to right from the beginning and is painful to change later, the same comparison argues, and the feedback loop is long. The workarounds outlive the versions too: the contortions a for loop needed back in Terraform 0.11 got better, and the habit of writing around the language stayed.

One piece of folklore to retire while we’re here: YAML did not start life as JSON with comments. The YAML 1.2 specification made JSON a strict subset of YAML rather than the other way round, and it treats comments as a presentation detail that “must not have any effect on the serialization tree or representation graph”. True, and no comfort at all when you’re four tools deep into a release.

Code and data read differently

The interesting claim isn’t that Go is nicer to type than YAML. It’s that the two formats fail differently under review.

What actually changes when a manifest becomes Go code?

You start reading it as a process rather than as a document, and a certain class of mistake becomes loud. When Julien Bisconti converted part of Volvo Cars’ production manifests as an experiment, the conversion itself found bugs.

That matches what the project’s authors report from Helm: they converted a few charts to Lingon and found configuration mistakes that are obvious in Go and hard to debug in a template. The mechanism is mundane. In a program you organise things by how they’re built and what changes often, so two values that must match end up next to each other, named. In a 900-line manifest they end up 400 lines apart, and the only thing checking them is you.

The rest of the benefit is tooling you already have: autocompletion, type checking, go test, and no context switch, because the Kubernetes ecosystem is written in Go and so are the operators your team already maintains. This is where we disagree. Andrey’s objection is that if teachability is the worry, Python is kinder to the people you’re onboarding than Go. Julien’s answer is that the head start applies to a small codebase, and the codebase in question is millions of lines across three clouds. What he’s buying with Go is type safety, plus the context switching he no longer pays: the platform, the operators and the tests are all the same language.

Terraform state into a manifest, without the shell script

The YAML argument is the half of this that other projects already cover. The half that’s specific to Lingon is the state.

Why can’t Terraform build the cluster and configure it in one apply?

Because provider blocks are evaluated before the resources that would produce their credentials, so the Kubernetes provider needs an endpoint and a certificate that don’t exist yet. HashiCorp says so in the provider’s own documentation: resources that expose cluster credentials “SHOULD NOT be created in the same Terraform module where Kubernetes provider resources are also used”, because it leads to “intermittent and unpredictable errors which are hard to debug and diagnose”. The recommended shape is two separate apply operations with data sources carrying values between them.

Anyone who has tried the one-shot version knows the drill: terraform apply -target for the cluster, then the rest, and you are back to two steps glued by hand. The all-Kubernetes route has the same shape from the other end. Describe your cloud resources as custom resources, and the bucket is created by a controller instead of a provider, but the loops and conditionals you wanted are now even further away, because YAML gives you anchors and not much else.

Lingon takes the seam itself as the thing to automate. You still write Terraform and you still write Kubernetes objects, both as Go structs. terra.Export writes the HCL, the Terraform CLI applies it, and terraform show -json prints the state in the machine-readable form HashiCorp documents, which the program then decodes into Go structs. The role ARN that came out of the apply goes straight into the service account you’re about to send to kubectl, in the same program, with the compiler watching. The shortest description of the result: Pulumi with better support for Go.

Where Lingon sits in your repo

A fair question at this point is what you delete to make room for it.

What does Lingon replace in my repo?

The handwritten manifests, the HCL and the shell glue you choose to convert, and nothing underneath them. Go becomes the place those three are written and connected. HCL is still generated and still applied by the Terraform CLI, manifests are still YAML by the time kubectl sees them, and state still lives wherever you put it.

The useful comparison is Terragrunt, which many teams already run: a binary that wraps the Terraform binary and adds hooks, dependency wiring and backend configuration. Lingon stops short of that. It’s a package you import into a program you write and own, which is why it can stop at being small. The example platform in the repository builds a VPC, the IAM roles, an EKS cluster, Karpenter for node autoscaling, Grafana and an RDS instance, and it ships as one Go binary you run with -plan or -apply.

Adoption is meant to be piecemeal for the same reason. kube.Import turns existing YAML into Go, including CRDs from projects as large as Istio and Knative, and kube.Export turns it back, so you can move one troublesome manifest, keep the other hundred as they are, and still hand a reviewer the YAML diff.

The escape hatch is the point

Keeping the library small only works if it also keeps you free, which is where the comparison with the declarative tools gets sharp.

What do you do when the tool has no option for your edge case?

You write the code yourself, if the tool lets you. Crossplane is the example that came up, and it deserves its credit first: the amount of engineering in it is genuinely impressive, and for teams that want a Kubernetes-shaped control plane for cloud resources it does what it says. Two things in it bite. Crossplane installs into an existing Kubernetes cluster, so you need a cluster to manage your clusters. And when something doesn’t happen, you find out by waiting: apply the manifest, notice the resource isn’t there, then go back through kubectl, logs and events in four terminals to find out why.

Then there are the edges. Go and try to delete a non-empty S3 bucket through a controller and see how far the YAML takes you. The AWS provider documents a switch for exactly this case, force_destroy on aws_s3_bucket, which empties the bucket when the bucket is destroyed. When a tool has no such hook, you have no way to make your case work, and the honest options are a half-finished documentation page, Stack Overflow, or a patched fork.

In a Go program the escape hatch is just the next line. Call the AWS, Google or Azure SDK directly for an API no provider has caught up with yet. Change authentication in flight when one account is read-only and another is admin. Use a different role per execution if your access model says you should. None of that is free, and all of it is possible without leaving the program.

What becomes possible once the glue is code

That freedom is only worth paying for if it buys back real work, so here is the work.

Which jobs get easier when the glue is a program?

The long checklists, starting with the ones nobody wants to automate because they only come up twice a year. A database migration is the example the project was proved on: take a snapshot, create the new instance, restore into it, reconnect the application that reads from it, verify. Written as a program, you have to answer a question you were previously answering at 1am, which is what each step failing actually means.

The use cases listed in the readme are the same idea applied in other directions. Keep the infrastructure state in a variable and you can store it in a database and query it later. Enforce rules on manifests before they’re deployed, such as every service account being bound to a role and no role carrying * in its access rights. Run a smoke test over HTTP, gRPC or a database connection right after the deploy, instead of watching a dashboard for twenty minutes. Collect metrics on which deployment steps fail and how often.

Post-deploy checks are not exclusive to this approach, and nobody should pretend otherwise. Helm has shipped helm test for years, and the test it scaffolds by default is a pod that runs wget against the released service (chart tests documentation). What a Go deployment program adds is that the check runs in the same process that holds the state, so provenance and health can be checked together rather than by two tools that never meet.

None of this needs Lingon specifically. It needs the deploy to be a program, in a language with a test runner and a cloud SDK, which is a bar your platform team can clear in several ways.

Or you could not run Kubernetes at all

There is a cheaper answer to the two-context problem, and it came up as a disagreement rather than a point.

Would ECS make this whole problem go away?

For a single-cloud setup, largely yes, and that’s Andrey’s position: run ECS on AWS, keep everything in Terraform, one API, one authentication model, one state file, and the second context never exists to be bridged. No manifests, no cluster add-ons, no provider that can’t initialise until a cluster exists.

Julien doesn’t dispute the engineering. He’s quick to agree it would be easier, and just as quick to point out that it wasn’t his choice to make. Andrey’s counter is that a consultant always has a choice, including walking away from the contract, which got the answer it deserved: “I can sell hot dogs on the street as well.” The useful version of the argument for you is the order of the questions. Ask whether you need the second context before you invest in bridging it, because a bridge you don’t build costs nothing to maintain. Once Kubernetes is a given, across clouds, with CRDs and operators your team already owns, bridging it with code is the option that fit the requirements here.

What this means for teams

If you run one cloud and one cluster, none of this is urgent. The argument lands when you manage platforms rather than an application, when your YAML is measured in tens of thousands of lines, and when a chunk of your week goes on gluing tools to other tools. The test is simple: count how much of your deployment logic lives in Bash and in CI step definitions, and ask what would have to be true for that code to be testable.

Four things worth doing this week.

  • Find your worst seam. Pick the one place where a Terraform output reaches a Kubernetes manifest through a script or a human, and write down what happens when that value changes.
  • Convert one manifest and read it. Render the chart with helm template first if it is a chart, then run kygo over the resulting manifests, read the Go, and see whether anything screams. You can throw the output away afterwards.
  • Split the apply you shouldn’t have joined. If one Terraform configuration builds a cluster and also configures it, separate the two applies and pass values through data sources, as the provider documentation asks.
  • Automate one checklist end to end, in whatever language your team already tests in. A database migration or a certificate rotation, with the failure branches written down. The value is in answering what each failed step means, not in the tool you pick.

Common questions, answered

Can I move one Kubernetes manifest to Go without rewriting everything?

Yes, and the round trip is designed for it. kube.Import converts YAML manifests to Go structs, including custom resource definitions, and kube.Export converts Go back to YAML, so a converted manifest still produces a diff your reviewers recognise and still goes out through kubectl. The kygo binary does the same conversion from the command line, on manifests rather than chart templates, so render a Helm chart with helm template first. Nothing forces the rest of your repository to follow.

Do I still need Terraform and kubectl if I use Lingon?

Yes, both, plus Go. Lingon generates HCL from Go structs and hands it to the Terraform CLI; it ships no Terraform client of its own, and the documentation points at terraform-exec if you want one. State stays in your existing backend, and terraform show -json is how it comes back out in a form a program can decode. You still need to know both tools, which the project states outright: it does not try to hide Terraform or Kubernetes.

Is infrastructure in Go harder to hand over than YAML?

That depends on what the next team already knows: this route asks for Go, Terraform and Kubernetes together, and a team short of one of the three will find the Go version harder rather than easier. Lingon itself adds little, since its API surface is small: import YAML into Go, export Go back to YAML, generate a provider’s Go types, export a stack to HCL, and import a Terraform state back into those structs. The plan and apply runs are your own program calling the Terraform CLI, not library API to learn. The alternative is not free either: a platform glued together with Bash, overlays and templates has its own learning curve. Write down which of the two your team can test.

Resources

Since we recorded

A month after this episode, HashiCorp moved Terraform to the Business Source License, which matters for anything that shells out to the Terraform binary as part of a product; we covered the fallout and the fork in episode 54 and the practical migration in episode 64. Lingon itself outlived its original home: the Volvo Cars project it was built for ended, Julien Bisconti and Jacob Lärfors moved the code to github.com/golingon/lingon and kept maintaining it, and the repository was archived in August 2025. The underlying question did not go away, and we returned to infrastructure composition and GitOps in Infrastructure as Code in 2026.