我有两个模块。
- 一个叫
module-azure-vnet
- 第二个叫做
module-azure-vm-instance-zabbix-proxy
我想将 Outputs 从 module 传递module-azure-vnet
到 module module-azure-vm-instance-zabbix-proxy
。第一个模块工作正常,但第二个模块需要子网、安全组和路由的输入。
主文件
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}"
}
错误:资源“azurerm_network_interface.no_public_ip”配置:变量 azurerm_subnet.wan.id 中引用的未知资源“azurerm_subnet.wan”
错误:资源 'azurerm_network_security_rule.security_rule_default' 配置:变量 azurerm_network_security_group.wan.name 中引用的未知资源 'azurerm_network_security_group.wan'
错误:模块“module-azure-vm-instance-zabbix-proxy”:“azurerm_subnet”不是有效参数
在模块中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",
]
}