问题描述
我正在尝试将 cidr_blocks
动态分配给 ingress
的 aws_security_group
状态,如下所示:
resource "aws_security_group" "allow_tls" {
name = "saurabh_security_group"
ingress {
description = "TLS from VPC"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["${aws_eip.lb.public_ip}/32"]
}
tags = {
Name = "allow_tls"
}
}
但它失败并出现以下错误:
Error: Invalid operand
on reference.tf line 31,in resource "aws_security_group" "allow_tls":
31: cidr_blocks = [aws_eip.lb.public_ip/32]
|----------------
| aws_eip.lb.public_ip is "52.14.139.236"
Unsuitable value for left operand: a number is required.
我使用的 terraform 版本是 0.14.3
。我也只尝试过 cidr_blocks = ["aws_eip.lb.public_ip/32"]
,但也失败了。但我可以理解,因为这里涉及到一个字符串,所以这将失败。但是为什么上述方法不起作用我无法理解,因为在 v0.12 中同样有效,没有任何问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)