Terraform抛出"groupName不能与参数子网一起使用".或"VPC安全组不可用于非VPC启动". [英] Terraform throws "groupName cannot be used with the parameter subnet" or "VPC security groups may not be used for a non-VPC launch"
本文介绍了Terraform抛出"groupName不能与参数子网一起使用".或"VPC安全组不可用于非VPC启动".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试弄清楚如何使用AWS VPC配置aws_instance
时,发生以下错误:
When trying to figure out how to configure a aws_instance
with AWS VPC the following errors occur:
* Error launching source instance: InvalidParameterCombination: The parameter groupName cannot be used with the parameter subnet
status code: 400, request id: []
或
* Error launching source instance: InvalidParameterCombination: VPC security groups may not be used for a non-VPC launch
status code: 400, request id: []
推荐答案
这是由于安全组与实例相关联的原因.
This is due to how a security group is associated with an instance.
没有子网,可以使用安全组的名称将其关联:
Without a subnet it is OK to associate it using the security group's name:
resource "aws_instance" "server" {
...
security_groups = [ "${aws_security_group.my_security_group.name}" ]
}
在还关联了子网的情况下,您不能使用该名称,而应该使用安全组的ID:
In the case where a subnet is also associated you cannot use the name, but should instead use the security group's ID:
security_groups = [ "${aws_security_group.my_security_group.id}" ]
subnet_id = "${aws_subnet.my_subnet.id}"
以上假设您已经创建了一个名为my_security_group
的安全组和一个名为my_subnet
The above assumes you've created a security group named my_security_group
, and a subnet named my_subnet
这篇关于Terraform抛出"groupName不能与参数子网一起使用".或"VPC安全组不可用于非VPC启动".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文