CIDR到IP范围以便在不了解CIDR的防火墙定义中使用(如azurerm_sql_firewall_rule)?

问题描述 投票:0回答:1

我有一堆CIDR,需要将其馈送到azurerm_sql_firewall_rule。不幸的是,后者需要<start IP, end IP>对。

有没有办法在Terraform中做到这一点?

terraform ip-address cidr
1个回答
0
投票
locals { cidr = "10.12.127.0/20" bits = 32 - split("/", local.cidr)[1] x = cidrhost(local.cidr, 0) y = cidrhost(local.cidr, pow(2, local.bits) - 1) } output "x" { value = local.x } output "y" { value = local.y }

正在运行:

Outputs:

x = 10.12.112.0
y = 10.12.127.255
© www.soinside.com 2019 - 2024. All rights reserved.