[英]Error when creating multiple instances and one network interface using terraform
My task is to create two instances, and attach one.network address with two private IP. Unfortunately, when creating instances, the IP for the first instance is attached, and the second instance simply dies.我的任务是创建两个实例,并附加一个带有两个私有 IP 的网络地址。不幸的是,在创建实例时,附加了第一个实例的 IP,而第二个实例就死了。 The error says that the IP is being used.
该错误表明正在使用 IP。 Conclusion, as far as I understand, when creating a second instance, it refers to the first IP, which is already assigned to the first instance.
结论,据我了解,创建二实例时,引用的是第一个IP,已经赋值给一实例了。 I will be grateful for the answer.
我将不胜感激。 Below I have attached the implementation code.
下面我附上了实现代码。 My error I got looks like this:
我得到的错误看起来像这样:
aws_instance.dev-elasticsearch[0]: Creating...
Error: Error launching source instance: InvalidNetworkInterface.InUse: Interface: [eni-0072af3215e4d6943] in use.
status code: 400, request id: 639b2e67-2539-426c-9f8d-17d0c6f8a0c5
My code:我的代码:
resource "aws_network_interface" "private_elasticsearch" {
subnet_id = aws_subnet.private_subnets.id
private_ips = ["10.245.10.6", "10.245.10.7"]
security_groups = [aws_security_group.elastic_traffic.id, aws_security_group.general.id]
tags = {
Environment = "Test"
Project = "test"
Name = "elasticsearch-interface"
}
}
resource "aws_instance" "dev-elasticsearch" {
count = 2
ami = "ami-08bdc08970fcbd34a"
availability_zone = "eu-north-1a"
instance_type = "t3.micro"
network_interface {
device_index=0
network_interface_id = aws_network_interface.private_elasticsearch.id
}
tags = {
Environment = "Test"
Project = "test"
Name = "elasticsearch-instance-dev"
}
}
You need two interfaces , since single interface can be attached to only a single instance.您需要两个接口,因为单个接口只能连接到一个实例。 So if you have two instances, you need two separate interfaces, not a single interface.
所以如果你有两个实例,你需要两个独立的接口,而不是一个接口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.