Error which we got while destroying. Refer Here for the fix
Deploying the application on the linux vm
This will be done post the 3 acvitity
Activity 3: Create a ntier architecture in Azure
Reference Architecture
In Azure Every resource has to belong to a resource group
Now lets create a virtual Network
In Azure
any resource by default is public if it has public ip & private if it doesnot have public ip.
To route the traffic from internet into vnet and with in vnet we dont need to create a route table because this is part of default routing.
Linux Virtual machines support key based authentication as well as password based authentication. User needs to provide username & Key/password
Now after creating vnet look into the resource
Now lets create a linux vm with ubuntu in web1 subnet
Once the vm is create let try to login into the vm
Now for realizing this activity in Azure using terraform we need a provider Refer Herefor the azurerm provider
This can be done by adding the provider.tf with the following and now execute terraform init
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.46.0"
}
}
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
}
Authentication in Azure from terraform can be done in multiple ways, generally on ci based systems we would use service prinicipal approach Refer Here and in developer systems we can use cli based approach. Refer Here
To review all the authentication mechanisms Refer Here
Lets try to configure azure with Service Principal
Launch Cloud Shell
Now run the following commands and make a note of client_id, client_secret and tenant_id. and then in the next command make a note of subscription id
az ad sp create-for-rbac --role Contributor --query "{client_id: appId, client_secret: password, tenant_id: tenant}"
az account show --query "{subscription_id: id}"
We can pass client id, client secret, tenant_id and subscription_id from arguments of the provider. But it is not a good practice