This is exciting; for one reason or another it seems you feel the need to start interacting with Azure using HashiCorp’s Infrastructure-as-Code tool, Terraform. Happy days indeed!
Before we start banging out resources though lets go through setting up your local environment - here’s what you’ll need:
graph TD
AS[Access to an Azure subscription] --> D(Start writing Terraform!)
AZ[Install Azure CLI] --> D
T[Install Terraform] --> D
C[Create a new
working directory] --> D
V[Install VS Code + extensions] --> D
classDef azure fill:#085FAD,stroke:#003B70,color:#ffffff;
classDef terraform fill:#623CE4,stroke:#3A1E9E,color:#ffffff;
classDef vscode fill:#559185,stroke:#003B70,color:#ffffff;
classDef neutral fill:#D3D0A7,stroke:#333,color:#111111;
classDef deploy fill:#05A000,stroke:#3A1E9E,color:#ffffff,font-size:18px;
class AS,AZ azure;
class T terraform;
class V vscode;
class C neutral;
class D deploy;
It might look like a lot but consider it an investment in your Terraform + Azure journey - we’ll step through how to get started on each of these things below.
Access to an Azure subscription#
An Azure subscription is a logical bucket which can contain cloud resources. Terraform deployments target a subscription, so if you really want to get your hands dirty with Terraform you have to sign up for an Azure account/tenant which should have a subscription ready to go.
If you don’t have an Azure account sign up via this link or just Google for ‘Getting started with Azure’. It is a bit of a process so grab your credit/debit card along with a ☕ (or beverage of choice) and get cracking. I’m not going to spend any time on this process as the onboarding journey should be pretty straight-forward.
Think about your tenant and what you might want from it over time - is this just a playground for basic things or do you want to build it out over time? It might be tempting to call it something cavalier like MonkeyButtTest, though consider one day you might want to host some longer-lived resources, attach a domain, or show a potential employer what you’ve designed & built - so name it accordingly.
Cloud resources cost money - you are responsible for managing costs and budgets, along with ensuring your account details are secure to avoid a malicious actor compromising your tenant and spending all your money.
If you’ve managed to onboard successfully, you should be able to:
- Log into the Azure Portal
- Search for and navigate to
Subscriptionsvia the portal search bar in the centre-top of the page - Observe one subscription that’s ready to rock
Install Azure CLI#
Azure CLI is a command line tool that can interact with Azure and Entra using az commands, such as this one to create a resource group:
az group create --location uksouth --resource-group "rg-test-resource-group".
For simple local development Terraform + Azure CLI work well together, we’ll talk more about this in subsequent lessons. Check out the install guide for Azure CLI, it’s extensive and generally should be fairly straight forward to install.
You’ll know installation has been successful when you can run az version in your shell of choice and it returns something like:
{
"azure-cli": "2.XX.0",
"azure-cli-core": "2.XX.0",
"azure-cli-telemetry": "1.1.0",
"extensions": {}
}As a fun side note if you’re wondering why there’s lots of ways to interact with Azure, it’s because there is! Ultimately, everything will go through the Azure Resource Manager so you can select the best tool for the job knowing that despite the quirks of each tool, it all goes through the same gate.
graph TD
AP[Azure portal] --> ARM[Azure Resource Manager]
APS[Azure PowerShell] --> SDK[SDKs]
SDK --> ARM
ACL[Azure CLI] --> SDK
RC[REST clients] --> ARM
ARM --> R[Azure resources]
classDef azure fill:#085FAD,stroke:#003B70,color:#ffffff;
classDef sdk fill:#623CE4,stroke:#3A1E9E,color:#ffffff;
classDef arm fill:#05A000,stroke:#3A1E9E,color:#ffffff;
class AP,APS,ACL,RC azure;
class SDK sdk;
class ARM arm;
Install Terraform#
Terraform can be installed numerous ways and the end goal is to be able to run terraform version in your shell of choice and have it return something like:
Terraform v1.XX.Y
on linux_amd64Terraform is just a single binary/executable file so if you’re getting super stuck, try downloading and extracting it into your working directory that we’ll set up next. Ideally though it should be in a system path location so that you can run terraform from any location and it will work.
If terraform (or any other executable) works but you can’t remember where it installed to, you can run Get-Command terraform | fl on Windows Terminal (PowerShell) or which terraform on Linux (and I think MacOS too) terminal - this should give you the full path to the binary.
Create a new working directory#
All you need here is a blank directory on your local file system where we can make the magic happen. This directory will contain our terraform files (*.tf) and become our VS Code workspace - more on that later.
If you’re familiar with a source control you could set this up but it’s not essential at this stage.
Install VS Code + extensions#
Download VS Code for your target operating system. If you’re on Windows, consider the User Installer over the System Installer as this doesn’t require local administrator access. It also updates frequently so even if you have local admin access via a separate account, you’ll be banging that password in every few days.
The following extensions are incredibly helpful, I highly recommend installing them. Open up VS Code and go to the Extensions tab on the left-hand side, or open the links below and click Install.
- HashiCorp Terraform - provides auto-complete/intellisense for HashiCorp Configuration Language (HCL)
- Microsoft Terraform - adds additional auto-complete syntax specifically for Azure resources
Obviously AI is all the rage so if you have a Claude/Copilot/* account you can add those extensions too.
Wrapping up & what’s next?#
The last step is opening your working directory within VS Code by going to File -> Open Folder... and navigating/selecting the directory. It may prompt you about trusting the directory, choosing yes should be fine if it’s your local filesystem.
This is now your workspace and we’re ready to rock! I haven’t written the subsequent lessons yet but I’ll add links here once that’s done and we’ll start writing some Terraform with gusto!
As a final fun sendoff, if you thought some of this setup was a bit time consuming and you don’t want to do it again when you change devices, you’re on to something! There’s plenty of ways to streamline ones local development setup, but one option worth checking out is Development Containers (aka Dev Containers) which can ensure you always have access to your desired development environment anywhere you can run a container (which should be almost any machine these days).
VS Code supports developing inside containers, be sure to check it out at some point.
