Getting started with Terraform and Azure: Overview and Setup

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we are ready to use terraform with azure [Music] hello everyone i'm travis and this is cerraltos hashicorp terraform is the de facto solution for infrastructure as code although each cloud provider has a native solution for deploying resources terraform provides a uniform language and workflows that support it across multiple cloud sas and on-premises infrastructures it's also open source in this video we'll review the basics of terraform and get an environment ready to use terraform with azure before that please like smash that subscribe button and click the bell icon for notifications of new content it helps this channel and is greatly appreciated also check out my courses on azure virtual desktop and hybrid identities with azure ad the link is below i have to be honest i've overlooked terraform in the past not because there's anything wrong with terraform but because i don't typically work in multi-cloud environments and i've spent a lot of time learning arm templates and bicep terraform just hasn't been a priority infrastructure as code and devop pipelines continue to gain popularity and my own views on the right products to use is outweighed by what customers and clients use and overwhelmingly they want to use terraform so with that said welcome to the first of what i expect to be several videos on terraform the end goal is to integrate terraform with devops pipelines using azure devops and or github actions but let's not get ahead of ourselves let's start at the beginning with what terraform is and what we need to get started we can't talk about terraform without talking about infrastructure as code as infrastructure becomes more virtualized and abstract from hardware we no longer have to worry about deploying and configuring servers routers and switches and other hardware all with different interfaces and management tools what used to be physical hardware made by a variety of vendors is now virtualized by a cloud provider of your choice azure for this example terraform uses a declarative language to create and manage resources and remove them when they're no longer needed we can plan changes and see how the changes will impact the environment before we apply those changes and it prevents configuration drift with strict state management terraform provides a consistent way to deploy infrastructure across multiple cloud sas and on-premises services using code the code interacts with apis with what's called a provider a provider translates the terraform code to a format supported by that cloud service each terraform provider is maintained and updated in the terraform registry this is a directory of terraform providers available to the public the azure provider is called azure rm providers are updated with new features when they become available the terraform documentation lists all the resources available with a provider along with examples for each this is a frequent reference when building infrastructure with terraform but before we can get to that we need to set up an environment for writing terraform infrastructure as code in the demo coming up we're going to get a workstation ready for deploying resources to azure with terraform we start by installing terraform then we'll install the azure command line interface or cli once that's done we'll install vs code to use as our editor you don't need to use vs code as the editor but if you're just starting out it's a great option at a good price it's free let's get started with installing terraform the first step to using terraform is to download the executable from the hashicorp website the link is in the comments below or the corresponding blog post for this example we'll use the 64-bit windows version let's scroll down and there it is terraform is distributed as a single executable not an installer package we have to do some manual configuration to get this working properly before we extract the file let's open file explorer go to the c drive create a folder at the root of the c drive called terraform alternatively you could add this folder to any location you'd like just as long as you update that location in the path variable let's do that next let's go to system environment variables from system properties we'll go to environment variables go to system variables and find path and edit we can see the existing paths for this computer you could put this folder anywhere as long as you add that path here or you could put it in a location that already has a path let's create a new path for c terraform c colon backslash terraform click ok to exit out also if you're working on a non-windows computer you'll need to extract the executable and update the system path according to that os's requirements okay let's go to the download directory and let's extract the zip file we just downloaded and browse to c terraform and select folder and extract so now we have a terraform.exe we can change the view now we have terraform exe in the c terraform directory in the future if you have to upgrade terraform simply download the newest version and overwrite the previous terraform.exe file let's test the progress i'll close our file explorer and open a command prompt from here i'll type terraform version terraform version should give you a version number and response that indicates terraform is installed correctly if you don't get that message verify the terraform executable is in the correct directory and that the location is added to the path statement let's install the azure cli next we'll close this the azure command line interface or cli is used to connect to azure and deploy resources go to the azure cli download page the link of course is below we'll download the latest release once finished let's open up the download folder and we'll run the azure cli msi package accept the terms and install we'll follow the prompts to install the azure cli this will take a couple minutes to finish i'll pause here and come back once it's done the installation is complete we can finish let's test it open a new command prompt from here type a z version you should see output similar to what's on this screen that indicates the version and that azcli is installed we're making some progress let's move on to installing vs code next we'll close the command prompt and go to the vs code download page here we are at the download page and the link for this of course is in the comments below download the version that matches your os the user installer for windows is fine for this example and doesn't require admin permissions to install i'll use the 64-bit and that will start the download once finished let's go back to the download directory and we'll run the vs code executable click accept if you accept the terms we'll go next the default settings will work fine for this example so we can click through so it starts to install this will take a few seconds to finish there we go we finished installing vs code and we'll make sure that that checkbox to launch visual studio code is checked and click finish i'm going to switch my theme to light and make it a little bigger you can use whatever settings work best for you we have a couple more tasks before we finish go to extensions that's the cubes on the left with one of them jumping out we're going to install three extensions an extension is like a helper file for specific programming languages the extension adds features such as language support and autocomplete or other advanced features that make vs code easier to use notice the azure cli tool is recommended let's install that next search for terraform add the terraform extension published by hashicorp there are a few listed here so make sure it's the one published by hashicorp next search for bracket pair colorizer i'll make this a little bigger add the bracket pair colorizer version 2. this is optional but it's helpful for keeping formatting in order especially for more complex files great we've got that installed we can close this one last thing before we're done go to terminal new terminal enter terraform version we should see the same output that we saw previously next enter a z version that's good it's giving us the version that means we've got terraform and the azcli installed correctly and that's it we now have an environment that's ready to start working with terraform i hope that helps you get started with terraform don't forget to subscribe and click the bell icon for notifications of new content like the next terraform video thanks for watching
Info
Channel: Travis Roberts
Views: 24,801
Rating: undefined out of 5
Keywords: Azure, Azure CLI, IaC Terraform, Terraform Registry, VSCode, Terraform for Azure, registry, .tf, HashiCorp, devops
Id: PD8OR4Tmjxo
Channel Id: undefined
Length: 10min 41sec (641 seconds)
Published: Mon Nov 29 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.