Azure Ntier Architecture
-
Overview
- Create network and subnets Refer Here
- Create a webnsg where
- 80,443 and 22 port are open from anywhere
- Refer Here for the changes done to add web nsg
- Now add app nsg which opens 8000 port within network Refer Here for changes done
- create a public ip address Refer Here for the changes
- create a network interface in web subnet with public ip and web nsg attached Refer Here for changes
- now attach network interface to the vm
- while creating the vm specify
- size
- os image
- Refer Here for official docs of microsoft azure to create linux vm from terraform
- Refer Here
Datasource
- We can use Datasource in terraform to fetch the information about resource
- Refer Here for official docs
- View the classroom recording for examples
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "4.3.0"
}
aws = {
source = "hashicorp/aws"
version = "5.68.0"
}
}
}
provider "azurerm" {
features {}
}
provider "aws" {
}
# lets fetch default vpc id of mumbai region
data "aws_vpc" "default" {
default = true
}
output "default-vpc-id" {
value = data.aws_vpc.default.id
}
data "azurerm_network_security_group" "web" {
name = "web"
resource_group_name = "ntier"
}
output "nsg_id" {
value = data.azurerm_network_security_group.web.id
}
# get the resource group name and location and create a new network
data "azurerm_resource_group" "base" {
name = "ntier1"
}
resource "azurerm_virtual_network" "new" {
name = "new"
resource_group_name = data.azurerm_resource_group.base.name
location = data.azurerm_resource_group.base.location
address_space = ["10.0.0.0/16"]
}
