简体   繁体   English

使用 terraform 创建多个实例和一个网络接口时出错

[英]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.

相关问题 使用每个 terraform 在单独的 AZ 中创建不同的 EC2 实例 - Creating different EC2 instances in separate AZs using for each terraform 为sqs及其访问策略创建terraform代码时出现循环错误 - cycle error when creating terraform code for sqs and its access policy Terraform 错误:错误:创建 Su.net:原始错误:代码 =“NetcfgInvalidSu.net”消息 =“Su.net'内部'在 virtual.network 中无效 - Terraform error: Error: creating Subnet: Original Error: Code="NetcfgInvalidSubnet" Message="Subnet 'internal' is not valid in virtual network 使用 terraform 创建 aks 集群时出现 Hashicorp 提供程序错误 - Getting Hashicorp Provider Error while creating aks cluster using terraform 使用 Flutter Firestore 插件时的最佳做法是什么? 是否应该避免创建多个实例? - What are the best practices when using Flutter Firestore plugin? Should creating multiple instances be avoided? Terraform 创建原则时出错 - Terraform error while creating principles 为 alb 侦听器规则创建动态 Terraform 规则时出错 - Error when creating dynamic terraform rule for alb listener rule 使用 AWS CLI 创建实例时如何禁用 SourceDestCheck - How does one disable SourceDestCheck when creating instances with AWS CLI Terraform - 创建多个 EBS 卷 - Terraform - creating multiple EBS volumes 如何使用 Terraform 从单个 VPC 启动多个 AWS EC2 实例? - How to launch multiple AWS EC2 instances from a single VPC using Terraform?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM