I have two modules.
- one is called
module-azure-vnet
- second is called
module-azure-vm-instance-zabbix-proxy
I want to pass Outputs from module module-azure-vnet
to module module-azure-vm-instance-zabbix-proxy
. First module is working properly, but second needs inputs for subnet, security group and route.
main.tf
module "module-azure-vnet-dtap" {
source = "/Users/username/project/module-azure-vnet-dtap"
}
variable "subnets_id_wan" {}
module "module-azure-vm-instance-zabbix-proxy" {
source = "/Users/username/project/module-azure-vm-instance-zabbix-proxy"
azurerm_subnet = "${module.module-azure-vnet-dtap.azurerm_subnet.wan.id}"
}
Error: resource 'azurerm_network_interface.no_public_ip' config: unknown resource 'azurerm_subnet.wan' referenced in variable azurerm_subnet.wan.id
Error: resource 'azurerm_network_security_rule.security_rule_default' config: unknown resource 'azurerm_network_security_group.wan' referenced in variable azurerm_network_security_group.wan.name
Error: module "module-azure-vm-instance-zabbix-proxy": "azurerm_subnet" is not a valid argument
In module module-azure-vnet-dtap
resource "azurerm_subnet" "wan" {
count = "${var.enable_wan_subnet ? 1 : 0}"
provider = "azurerm.base"
name = "${format("%s-%s-%s", var.environment_name, "WAN", "Subnet")}"
virtual_network_name = "${azurerm_virtual_network.this.name}"
resource_group_name = "${azurerm_resource_group.this.name}"
address_prefix = "${cidrsubnet(var.cidr_block,5,count.index)}"
route_table_id = "${azurerm_route_table.wan.id}"
network_security_group_id = "${azurerm_network_security_group.wan.id}"
}
resource "azurerm_network_security_group" "wan" {
count = "${var.enable_wan_subnet ? 1 : 0}"
provider = "azurerm.base"
name = "${format("%s-%s", var.environment_name, "WAN-Subnet-Security-Group")}"
location = "${azurerm_resource_group.this.location}"
resource_group_name = "${azurerm_resource_group.this.name}"
}
output "subnets_id_wan" {
value = "${azurerm_subnet.wan.*.id}"
depends_on = [
"azurerm_subnet.wan",
]
}
module "module-azure-vm-instance-zabbix-proxy"
block and then runterraform init && terraform refresh && terraform show | less
and look at all the output names and values to see if the module is outputting the correct value or if you're passing in the correct output to the zabbix proxy module. – SomeGuyOnAComputer