Hi,
I’m getting an error which I am not sure why. So I have this:
# Create public IP
resource "azurerm_public_ip" "nix-ip" {
name = "nix-public-ip"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
allocation_method = "Static"
}
resource "azurerm_subnet" "subnet-dmz" {
name = "subnet"
resource_group_name = azurerm_resource_group.main.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = [var.dmz_subnet_cidr]
}
# Creat NIC
resource "azurerm_network_interface" "nix_nic" {
name = "nix-nic"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
ip_configuration {
name = "static"
subnet_id = azurerm_subnet.subnet-dmz.id
private_ip_address_allocation = "Static"
private_ip_address = cidrhost(var.dmz_subnet_cidr, 10)
public_ip_address_id = azurerm_public_ip.nix-ip.id
}
}
In my vars.tf file, I have this:
variable "dmz_subnet_cidr" {
description = "CIDR to use for the DMZ subnet"
default = "10.0.4.0/24"
}
variable "lan_subnet_cidr" {
description = "CIDR to use for the lan subnet"
default = "10.0.3.0/24"
}
Then I get this error
But why does it say IP address 10.0.4.10 doesn’t work to use here? That IP is correct for this linux.tf file I am creating since it should be in the dmz_subnet_cidr, and not in lan_subnet_cidr? Not sure why terraform requires me to have that IP in the wrong subnet(10.0.3.0/24)?