问题 It's sad that terraform is not backward compatible. data "aws_security_group" "security_groupdev" { filter { name = "group-name" values = ["SecurityGroupdev"] } } resource "aws_instance" "ec2_instance" { count = "${var.ec2_instance_count}" ... } resource "aws_network_interface_sg_attachment" "sg_attachment" { security_group_id = "${data.aws_security_group.security_groupdev.id}" network_interface_id = "${aws_instance.ec2_instance.primary_network_interface_id}" } but after upgrading it to