terraformterraform-provider-gcptektontekton-pipelines

Tekton and Terraform order of operation


Trying to use Tekton CI/CD along with Terraform for IaC (Infrastructure-as-Code). Did not find tutorial or resources online that explains how these two operate together. So I would appreciate explanations how they work together.

In particular, this is my question: Do I need to run terraform apply to create the infrastructure before Tekton pipeline is run? Or does Tekton run terraform to create infrastructure?

Thank you!


Solution

  • Tekton is where you create your "pipeline" of "tasks" to be completed, in sequential order. A Tekton Task will most likely be calling Terraform to perform some work. So for example, the first Task could be to call Terraform to setup the infrastructure (IE> deploy network functions, program code, configure routers/switches, etc.), then a subsequent Task might be to install an Application that uses that infrastructure via another Terraform directory, and a third task might be to configure that app -- again using another Terraform directory. Three Tasks in a row => Pipeline.

    You are right that there is very little content out there about how to use Tekton with Terraform. Here is a link to a post that helped me the most: https://spacelift.io/blog/terraform-in-ci-cd

    Tekton, by itself, isn't something that configures things -- it only runs Tasks and figures out if the Task was successful. If so, run the next task. If not, stop and complain. Tekton can call just about anything to help complete its Tasks. I have one Pipeline that uses Python, Ansible, Terraform, and a couple of compiled GOlang programs to install and deliver a Cloud Application, along with the required changes to Routers & Switches, and installs and configures an ADC to provide secure access to that App.