【发布时间】:2020-05-03 15:03:23
【问题描述】:
我正在尝试使用 terraform 创建 3 个 EC2 实例,其中两个私有 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"
}
}
【问题讨论】:
标签: amazon-web-services amazon-ec2 terraform devops terraform-provider-aws