我正在尝试使用terraform创建3个EC2实例,并使用terraform将两个私有IP附加到eth0和eth1,您能建议我使用正确的Terraform资源来创建辅助私有IP地址并将其附加到每台EC2机器上吗。
我知道默认情况下它会创建eth0并附加一个私有IP地址,我希望创建eth1作为实例创建的一部分,并附加来自另一个子网的私有IP。
resource "aws_instance" "test" {
count = "${var.instance_count["test"]}"
ami = "${var.ami}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
vpc_security_group_ids = ["${aws_security_group.kafka_sg.id}"]
associate_public_ip_address = "${var.associate_public_ip_address}"
ebs_optimized = "${var.ebs_optimized}"
disable_api_termination = "${var.disable_api_termination}"
subnet_id = "${var.subnet_id}"
user_data = "${base64encode(file("${path.module}/mount.sh"))}"
tags = {
Name = "test-${var.instance_prefix}-${format("%02d", count.index+1)}"
}
root_block_device {
volume_type = "${var.root_volume_type}"
volume_size = "${var.root_volume_size}"
}
ebs_block_device{
device_name = "/dev/sdb"
volume_size = 10
volume_type = "gp2"
}
}
答案 0 :(得分:0)
通过aws_network_interface创建ENI,然后通过aws_network_interface_attachment附加ENI,向服务器添加弹性网络接口。