Setup Terraform On macOS And Windows for Azure Deployments

In this blog post, I will show you how to get started with Terraform and Microsoft Azure using VS Code and Azure CLI and get your macOS and Windows machine ready.

In a previous blog post, I showed you how to use Terraform with Cloud Shell which is good for small and quick tasks, this time I will show you how to get it working on you Windows or macOS machines.

PowerShell 7

The first thing that we need before we use Terraform on a macOS or Windows is installing PowerShell 7. Please use the following post for macOS and Windows to get it.

Azure CLI

Next we need to install Azure CLI, which will allow us to authenticate to Azure. Below I will show you how to install it on macOS and Windows.

For macOS run the following command:

brew update && brew install azure-cli

For Windows, you will need to download the Azure CLI installer (MSI) and run it on your machines. Please use the following blog post to review the process.

Install Terraform

The final step is to install Terraform on your machines, which I will show you how to install it on macOS and Windows. Please note that Terraform offers the installer as a manual install and as a package using a package management utility.

For Windows please use Chocolatey (you will need to install it first). Once you have Chocolatey installed run the following command.

choco install terraform

For macOS I will use Homebrew and run the following command to install Terraform,

brew install terraform

Git – gitignore

If you are using Git for version control, make sure you create or add the following entries to your gitignore file otherwise the Terraform plugin folder will get to big to sync with GitHub.

.terraform

At this stage, your machine is ready to connect and deploy workloads to Azure without using Cloud Shell. In the next post, we will learn how to create a Virtual Machine Azure. Please click to view the post on how to create a VM in Azure With Terraform.


Posted

in

by