Create NEW Azure RG

I’m creating new VNET in Azure and it works fine if I’m reusing an existing Resource group name. If try to create new Resource Group it fails the code. Are you able to create new Resource group?

variable “resource_group_name” {
description = “Resource group name”
type = string
default = “myrg”

module “vnet-main” {
source = “Azure/vnet/azurerm”
resource_group_name = #Calling the variable.
#location = var.location
vnet_name = var.vnet_name
address_space = [“”]
subnet_prefixes = var.subnet_prefixes
subnet_names = var.subnet_names
nsg_ids = {}
tags = {
environment = “dev”


Error being received.

terraform plan -var resource_group_name=myrg -out vnet.tfplan

│ Error: Error: Resource Group “myrg” was not found

│ with,
│ on .terraform/modules/vnet-main/ line 2, in data “azurerm_resource_group” “vnet”:
│ 2: data azurerm_resource_group “vnet” {

Already fixed. Using resource instead of module for creating new VNET is working fine.
See the code I used.