My first Azure DevOps — Terraform Project!
- caseybond2
- Sep 12
- 5 min read

Intro and Preparation
So, I decided to jump into the cloud, which has many choices and paths. The first choice is which cloud platform? I experimented with AWS and Google Cloud, which I didn’t like very much, so I decided the cloud wasn’t for me.
Then I realized, 'Hmmm, I love Microsoft, Active Directory, and other applications they offer.' Maybe I should try Azure. I dove straight in, got my AZ-900 within two weeks, and will be testing for SC-900 next week. (I will write blogs for both AZ-900 and SC-900 soon) While researching the cloud, I heard one thing about 10000 times: TERRAFORM! It sounded daunting, and I figured I didn’t need to learn that.
I started to notice that every job posting I read required “Terraform” experience. I used to get annoyed, but after just messing with Terraform for one day, I can see why this is such a great IaC tool and resource! With that being said, let us get started! I plan to walk you through my first project, where I built a Dev environment with Terraform in Azure.
You need three main things to start the project, with some additional sub-installations.
Active Azure subscription (You can use Terraform with Azure, AWS, Google Cloud, and Oracle)
Terraform for Windows (This can be installed on Windows, Mac, and Linux)
Visual Studio Code (Azure account Extension, Azure Terraform Extension)
The two resources I used to get started with the installation and preparation are listed below.
https://jeffbrown.tech/install-terraform-windows/ (This is a simple explanation of how to set up Terraform on your Windows computer properly)
https://courses.morethancertified.com/ (This is the course I follow and use to learn how to use Terraform properly)
Project Start!
To start, I already had an active Azure subscription and VS Code (Visual Studio Code) installed, so all I needed was to install Terraform. I also had to add the extensions in VS Code. Easy, right? Not so much!
I added the extension mentioned above, which is simple, but the installation of Terraform was a pain. After setting everything up, I thought I was ready to start coding. I found myself fighting the following error!

After about four hours of figuring out why commands would not run, I finally reached out on LinkedIn. I thought it was a permissions or installation issue in VS Code, but it turns out it was how Terraform was installed. To properly run the cmdlets through VS Code, Terraform must be installed and configured appropriately. If you follow the videos in the link listed above, you should have no issues (I accidentally skipped a video, which caused frustration). After about five hours in total, I finally got everything connected. Once this was set up, I followed along in the video using different resource links to see how code should be formatted and adequately placed. One useful command to clean up your code is “terraform fmt.” Make sure to get in the habit of using this!

resource “azurerm_resource_group” “example” {
name = “example”
location = “West Europe”
}
The code above is a simple example for creating a resource group with the name and location you specify. We used code to make the virtual network for our resource group, and I struggled with this because of a single space missing in a portion of my code. If you see the following response after completing code for a new resource you haven’t created, CHECK YOUR CODE!

Once I corrected the code, I deployed a virtual network. From here, we moved on to the concept of “The Terraform State,” which stores all the “states’ of your deployment. This is a valuable resource that, in most environments, is saved and stored remotely away from your working area. Below are some of the commands you can use to view the different resources and information related to the deployments of those resources using the Terraform state.
- Terraform state list
- Terraform state shows “name of resources from the list cmd”
- Terraform show
The Terraform state is beneficial because it contains the Terraform.tfstate file, which represents the current state of everything in your environment, and you will also have a Terraform.tfstate.backup file. If you have deleted or made a mistake, you can remove the .tfsstate file and rename the backup to recreate what is needed.
From here, we started building Subnets and security groups, and this was when I started making little mistakes I like to call “terraissues.” I plan to coin this term. Terraform issues are subtle little mistakes in the code that cause the deployment of the resources you are working with not to deploy correctly. This issue occurred when I attempted to create the security group — please see the error below.

The issue was resolved through a small amount of googling, but ultimately, in the code line — — resources “azurerm_network_security_group” “mtc-sg” — I first wrote “azure_network_security_group” “mtc-sg”. Do you see the difference? I never added the “rm” to the end of “azure”; this small typo in the code caused me to Google around for about an hour. Fun times!
The next issue was incorrectly labeling the entire location for the security group by referring to it as a .name instead of a .location. This took about another 45 minutes!
I hope that any first-time Terraformers read this and learn some of these lessons, which will make your life a little easier!
I don’t plan to bore you with the twenty other coding mistakes I made throughout this project, but I will share some lessons learned. Ensure to use CTRL + S, which will save you!! Literally, this keeps your work, and it’s essential to ensure that you save after each small portion of code.
As I write this, all these images look small and hard to read. I hope the photos will look all right when I publish the final copy of the blog.
Conclusion

Above is a snippet of the final code, about 150 lines of code that created an entire operations dev environment in Azure. Terraform is a fantastic resource, and if you are starting to explore the cloud, I recommend watching a video or trying one of these simple Terraform builds. This will provide you with a solid understanding of IaC (Infrastructure as Code), a topic you will often hear discussed.
Before completing this course, I didn’t think I fully understood the magnitude of IaC. The ability to make changes, deploy resources, and delete resources in AWS, Google Cloud, Azure, and Oracle from a single location increases productivity tenfold.
I know this blog post was very amateur, but I hope you enjoyed it and it pushes people to try something new! My upcoming blog posts will focus on the AZ-900 and SC-900 certifications.
Additional Resources!
Explore the additional resources from Spacelift, a sophisticated CI/CD platform that supports Terraform, CloudFormation, Pulumi, and Kubernetes.



Comments