Search code examples
continuous-integrationterraformcontinuous-deploymentcicdhashicorp

Combining Terraform wth CI/CD pipelines when provisioning is a rare event compared to usual code pushes


You see a lot of articles on combining GitHub actions with Terraform. It makes sense that anytime one wants to provision something different in their infrastructure that a CI/CD pipeline would add visibility and repeatability to an otherwise manual process.

But some article make it sound as though Terraform is doing the deploying of any change. For example, this article says "anytime there is a push to the src directory it will kick off the action which will have Terraform deploy the changes made to your website."

But doesn't this only make sense if the change you are making is related to provisioning infrastructure? Why would you want any code push to trigger a Terraform job if most pushes to the codecase have nothing to do with provisioning new infrastrucutre? Aren't most code pushes things like changing some CSS on the website, or adding a function to a back-end node script. These don't require provisioning new infrastructure, as the code is just placed onto existing infrastructure.

Or perhaps the article is suggesting the repo is dedicated only to Terraform.


Solution

  • In my case the changes are from terraform(only) repos. Any change to infra would be triggered by these repos. In rest of the actual app code, it would always be Ansible-Jenkins. Deploying terraform infrastructure change everytime there is a push to app-code might bring down the uptime of the application. In case of containerized application it would be Helm-kubernetes doing the application bit.