在Terraform中添加多种变量类型?
我想添加多个IP地址以在Azure中为App Service配置访问限制,并且仅在几个环境中才能实现这一目标,我使用动态块来实现此目的,只要只有一个IP,但是现在我想允许更多的IP地址,有没有办法实现这一目标?
dynamic "ip_restriction" {
for_each = var.ip_addresses
content {
ip_address = ip_restriction.value["ip_address"]
priority = ip_restriction.value["priority"]
name = ip_restriction.value["name"]
}
}
这很完美,但我也想添加环境限制。类似
for_each = var.env == "dev" || var.env == "qa" ? [1] : []
I want to add multiple ip addresses to configure access restrictions in azure for an app service and also this should be accomplished only for a few environments, I'm using the dynamic block to achieve this, it was working as long as there was only one IP, but now I want to allow more ip addresses, is there a way to achieve this?
dynamic "ip_restriction" {
for_each = var.ip_addresses
content {
ip_address = ip_restriction.value["ip_address"]
priority = ip_restriction.value["priority"]
name = ip_restriction.value["name"]
}
}
This works perfect but I want to add the environment restriction as well. something like
for_each = var.env == "dev" || var.env == "qa" ? [1] : []
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您真的很接近,您只需要更改此数组:
[1]
即可成为IP地址的实际数组,例如:You are really close, you just need to change this array:
[1]
to be the actual array of IP addresses, like so: