Search code examples
terraformgithub-actionskustomizeskaffold

How do I pass resources that were created by Terraform to Kustomize


Am using a combination of these tools

  • Terraform - To deploy the Application specific AWS resources I need (For instance a secret)
  • Skaffold - To help with the inner development loop, surrounding the deployment of K8s resources to local and remote cluster
  • Kustomize - To help with templating of different configurations for different environment

My github action steps are as follows

  • Terraform to create the AWS resources. At this point it creates a AWS secrets arn.
  • Skaffold to deploy the k8s manifests. Skaffold in-turn delegates K8s manifest generation to Kustomize. Within the Kustomize overlay files i need to be able to access the Secrets arn that was created earlier, this arn needs to be injected into the container that is being deployed. How do I achieve this?

Rephrasing the question: How do I pass resources that were created by terraform to be consumed by something like Kustomize (Which is used by skaffold)

(p.s, I really like the choice of my tools thus far as each one excels at one thing. I realize that terraform can possibly do all of it, but that is a choice that I dont want to make unless there are no easier options)


Solution

  • Here is what I have learnt: I don't think there are any industry standards in terms of how to share this data between the tools across different steps within github actions. That being said here are some of the options

    1. Have the Terraform store the secrets arn in a parameter store. Retrieve the arn from the parameter store in later steps. This means that the steps have to share a static key
    2. Have Terraform update the kustomize files directly (or use kustomize_overlays as datasource)

    There could be other similar approaches, but none of these tools have a native way of passing/sharing data