What is Terraform state
- Every time we run terraform it records information about the infrastructure it created in the Terraform state file. By default when we run terraform in a folder , terrafrom creates a file in the same folder
terraform.tfstate. - This file is in JSON format that records mapping of terraform resources in our configuration file to the representation of resources in the real world
- Note: This state file format is private API for terraform and changes for every release, we should never edit the terraform.tfstate file.
- When we can configure terraform in such a way that it stores the tfstate file in common location, we can use terraform with in a team
- This feature we will be learning soon & is called as Remote Backend.
- Now lets apply the infrastructure which we are building and view the state file
- Refer Here for the private route table.
Lets try to create the ntier with vm on Azure
- Architecture to be realized
- In the visual studio lets add an extension of terraform azure by microsoft
- The Azure provider for terraform Refer Here
- To get Azure Credentials
-
Login into Azure and launch cloud shell
-
Lets execute a command
az ad sp create-for-rbac --query "{client_id: appId, client_secret: password, tenant_id: tenant } -
Preserve the output to some notepad
-
Now execute the following command “`az account show –query "{ subscription_id: id}" and preserve the subscription id
-
- Creating a virtual network with three subnets
- Manually (refer classroom video as well)
- Manually (refer classroom video as well)
- Terraform configuration applied for azure Refer Here.
- Refer Here for the changeset containing changes to add network security group and network interface
- Now lets try to create an azure linux ubuntu vm
- Refer Here for the changeset
- Refer Here for the changeset
