Deploying Terraform using GitHub actions

<p>When working with AWS services I have been using Terraform as my Infra As Code. In the project I am currently working on I have a CI/CD pipeline for deploying project code using GitHub actions. However, I would now like to extend my pipeline to deploy any infrastructure changes when there are any.</p> <h1>The Goals</h1> <ul> <li>I want the terraform action to only run when there has been changes to a file within my terraform directory, it doesn&rsquo;t need to run on all code deployments</li> <li>I want to be able to view a plan of my terraform changes, when any infra changes are pushed up in a commit to a PR. This will allow any reviewers to review the changes and plan as well.</li> <li>I only want to proceed with a terraform deployment when the code has been merged into the main branch</li> </ul> <p><strong>TL;DR: If you are under time pressure, my working config is at the end of the blog with an explanation on how it works. I hope it helps!</strong></p> <p><a href="https://chloemcateer.medium.com/deploying-terraform-using-github-actions-20937d68160f"><strong>Visit Now</strong></a></p>