published: 19th of January 2023
In my last couple of posts, I have been building an AWS static site with Terraform and Terraform Cloud. In this post, I will show you how to connect your Terraform Cloud Workspace to a GitHub repo (that contains the Terraform code from the previous post). I will also configure the workspace to deploy the site automatically when there is push to the main branch of the repo.
Ok peeps! You ready to rock? Let's Party on Wayne 🤘
The first step is enabling the Terraform Workspace for remote execution. Browse to:
Then ensure that the Excution Mode is set to Remote and click Save settings.
Next up, set the workspace up for Version Controlled Workflow. Browse to:
Click on GitHub then select GitHub.com.
In the pop-up click Authorize Terraform Cloud.
Select the GitHub organization to install the Terraform Cloud app into.
I am enabling the app for Only selected repositories and only for the aws-static-site-tf repo.
Click Install once you have finished selecting repos.
Now, back on Terraform Cloud select the aws-static-site-tf repo to go to the settings page.
Set the Apply Method to Auto apply. Also, set the VCS branch to main then click Update VCS settings.
With this configuration in place, any push to the main branch of the repo will trigger a terraform apply -auto-approve run on Terraform Cloud, and the infrastructure defined in your Terraform code will be deployed automagically 🎸
Thanks for tuning in. In this post, I covered the process to connect your Terraform Cloud environment to a GitHub repo and automatically deploy infrastructure to AWS when there is a push to the main branch of the repo.
Devops Borat would be so proud.