Vnet and Subnet creation using terrafrom is not working

Terraform v0.12.26
    provider.azuread v0.10.0
    provider.azurerm v2.15.0
    provider.external v1.2.0
    provider.helm v0.10.5
    provider.kubernetes v1.11.3
    provider.local v1.4.0
    provider.null v2.1.2
    provider.random v2.2.1
    provider.template v2.1.2
    provider.tls v2.1.1

Terraform Configuration Files

I have 3 different configuration parts to create network and subnet:

1. Everything works, but the cluster rises in custom region network.

    esource "azurerm_virtual_network" "network" {
    name = "${var.prefix}-${var.environment}-vnet"
    address_space = var.vnet_cidr
    location = var.resource_group_location
    resource_group_name = var.resource_group_name

    subnet {
    name = "${var.prefix}-${var.environment}-subnet"
    address_prefix = var.subnet_cidr
    }
    }

Can’t use vnet_subnet_id because it’s no subnet.id for this part.

default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v3"
vnet_subnet_id = azurerm_subnet.subnet.id
}
  1. I can specify the subnet, everything rises as needed, but nginx does not expand.
    resource "azurerm_virtual_network" "network" {
    name = "${var.prefix}-${var.environment}-vnet"
    address_space = var.vnet_cidr
    location = var.resource_group_location
    resource_group_name = var.resource_group_name

resource "azurerm_subnet" "subnet" {
name = "${var.prefix}-${var.environment}-subnet"
resource_group_name = var.resource_group_name
virtual_network_name = azurerm_virtual_network.network.name
address_prefixes = var.subnet_cidr
}

default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v3"
vnet_subnet_id = azurerm_subnet.subnet.id
}
  1. The implementation of the first option through the data source, in order to get subnet_id. Terraform shows an error
    Error: Subnet "wm-test6-kubsubnet" (Virtual Network "wm-test6-vnet" / Resource Group "wm-test6") was not found.
All resources are created, uses of dependency doesn't help.
    resource "azurerm_virtual_network" "network" {
    name = "${var.prefix}-${var.environment}-vnet"
    address_space = var.vnet_cidr
    location = var.resource_group_location
    resource_group_name = var.resource_group_name

subnet {
name = "${var.prefix}-${var.environment}-subnet"
address_prefix = var.subnet_cidr
}
}

data "azurerm_resource_group" "rg" {
name = var.resource_group_name
depends_on = [azurerm_virtual_network.network]
}

data "azurerm_subnet" "k8ssubnet" {
name = "${var.prefix}-${var.environment}-kubsubnet"
virtual_network_name = azurerm_virtual_network.network.name
resource_group_name = var.resource_group_name
}

default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v3"
vnet_subnet_id = data.azurerm_subnet.k8ssubnet.id
}