Terraform deployment with Github actions

Our Cloud School
6 min readJul 14, 2023

In this blog I will share the template to deploy and manage azure infrastructure with terraform

Photo by Linus Mimietz on Unsplash

Lets say I have following azure infra code written in terraform and I would like to deploy this from github actions workflow


terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.64.0"
}
azuread = {
version = "=2.36.0"
}
}
}


provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
key_vault {
purge_soft_delete_on_destroy = true
}

api_management {
purge_soft_delete_on_destroy = true
}
}
}

resource "azurerm_resource_group" "rg" {
name = "rg-demo-01"
tags = {}
location = "uksouth"
}

Github Action/Workflow: You can define the pipeline in github action inside your repository.

To create an action you need to create a yaml (or yml) file inside you repository (.github/workflow/myaction.yml or .github/workflow/deployment.yaml)

Terraform deployment pipeline:

Here is the pipeline code:

Triggers:

first you are going to add a trigger point of pipeline

name: 'Terraform Deployment'

on…

--

--

Our Cloud School

Rakesh Suryawanshi — Azure Solutions Architect, DevOps with Terraform