How to Create a GitHub Actions Workflow to Deploy Terraform Code to Azure

Guillermo Musumeci
8 min readMay 4, 2024

In this story, we will create a GitHub Actions workflow to deploy Terraform code in Azure (without using Terraform Cloud).

This involves setting up a CI/CD pipeline that executes directly in our GitHub repository. This setup will handle the initialization, planning, and application of our Terraform code.

1. Prerequisites

Below is the list of prerequisites required to create a GitHub Actions CI/CD pipeline:

  • Azure Subscription: If we don't have an Azure subscription, we can create a free account at https://azure.microsoft.com before we start.
  • Azure Service Principal: This is an identity used to authenticate to Azure. Below are the instructions for creating one.
  • Azure Remote Backend for Terraform: we will store our Terraform state file in a remote backend location. We will need a Resource Group, an Azure Storage Account, and a Container.

2. Configuring the Remote Backend

We will need a place to store the Terraform state so that we will use an Azure Storage Account.

We must create a dedicated resource group, storage account, and a blob container in Azure.

--

--

Guillermo Musumeci

Certified AWS, Azure & GCP Architect | HashiCorp Ambassador | Terraform SME | KopiCloud Founder | ex-AWS | Entrepreneur | Book Author | Husband & Dad of ✌