Hi
I am trying to create virtual machine. But I am getting an error.
I am sending you my code. Can you guys check this code on your end and tell me what is the issue. Thanks
terraform {
required_providers {
azurerm = {
source = “hashicorp/azurerm”
version = “3.80.0”
}
}
}
provider “azurerm” {
features {}
client_id = “”
client_secret = “”
tenant_id = “”
subscription_id = “”
}
resource “azurerm_resource_group” “rg10” {
name = “rg10”
location = “West Europe”
}
resource “azurerm_virtual_network” “virtual_network” {
name = “vnet01”
address_space = [“10.0.0.0/16”]
location = “West Europe”
resource_group_name = “rg10”
depends_on = [ azurerm_resource_group.rg10 ]
}
resource “azurerm_subnet” “vnet_subnet” {
name = “subnet01”
resource_group_name = “rg10”
virtual_network_name = “vnet01”
address_prefixes = [“10.0.2.0/24”]
}
resource “azurerm_network_interface” “vm_interface” {
name = “interface01”
location = “West Europe”
resource_group_name = “rg10”
depends_on = [ azurerm_virtual_network.virtual_network ]
ip_configuration {
name = “testconfiguration1”
subnet_id = data.azurerm_subnet.subnet.id
private_ip_address_allocation = “Dynamic”
}
}
data “azurerm_subnet” “subnet” {
name = “subnet01”
virtual_network_name = “vnet01”
resource_group_name = “rg10”
}
resource “azurerm_virtual_machine” “virtual_machine” {
name = “vm01”
location = “West Europe”
resource_group_name = “rg10”
network_interface_ids = [azurerm_network_interface.vm_interface.id]
vm_size = “Standard_D2S_v3”
storage_image_reference {
publisher = “MicrosoftWindowsServer”
offer = “WindowsServer”
sku = “2019-Datacenter”
version = “latest”
}
storage_os_disk {
name = “myosdisk1”
caching = “ReadWrite”
managed_disk_type = “Standard_LRS”
create_option = “FromImage”
}
os_profile {
computer_name = “vm01”
admin_username = “testadmin”
admin_password = “Password1234@”
}
}
Regards