Terraform with Microsoft Azure — Part 2
Hi Friends,
In this section, we will continue from the last post and delve further into terraform. Having said that let’s get started.
The very first thing, which we need to do is to download the terraform executables from here. We need to download the required version. Installation is pretty simple, just download the same and put it some global accessible location. In-case of windows, its System32. I have placed the binary here. I can now go ahead and type terraform -version. This will return the below version
Next, let’s go ahead create terraform project. I have created with the name terraform-basic and created one file main.tf.
My snippet looks like this
provider "azurerm" {
version = "=2.0.0"
}
resource "azurerm_resource_group" "terraform-basic" {
name = "terraform-basic"
location = "eastus"
}
Having said that, my folder structure looks like
I have also installed two terraform extensions to help me with terrform options and with azure as well. They are
If I type anything in editor now, it will give me intellisense support like shown below.
Let’s say, I apply tags, then it will look like
Now, let me explain the code here.
Terraform initialization:
- We will learn about locking and other concepts in coming sections. Here, we can see that execution plan got created, which is nothing but executable file.
- I will now go ahead and run terraform apply “execplan.plan” command or from command palette itself like shown below.
- Since, we are destroying the resource, hence it will ask for the confirmation message like shown above. We just need to type yes and continue.
- It will show logs in the terminal that its destroying and in some time, it will print the confirmation message.
With this I would like to wrap this session. In the next session, we will delve deeper into terraform artifacts. Till then stay tuned and Happy Coding.
Thanks,
Rahul Sahay
Happy Coding
Originally published at https://myview.rahulnivi.net on March 23, 2020.