[英]How to spin the ec2 from Ami(with multiple volumes -3+) using terraform
想要使用 Terraform 从 AMI 和具有 4 个卷的 AMI 旋转 ec2。 非常感谢任何指针?
resource "aws_instance" "this" {
count = var.instance_count
ami = var.ami_id
instance_type = var.instance_type
key_name = var.key_name
iam_instance_profile = var.iam_instance_profile
disable_api_termination = var.enable_deletion_protection
user_data = var.user_data
network_interface {
network_interface_id = aws_network_interface.eth0[count.index].id
device_index = 0
}
dynamic "root_block_device" {
for_each = var.root_block_device
content {
delete_on_termination = lookup(root_block_device.value, "delete_on_termination", true)
encrypted = lookup(root_block_device.value, "encrypted", null)
iops = lookup(root_block_device.value, "iops", null)
kms_key_id = lookup(root_block_device.value, "kms_key_id", null)
volume_size = lookup(root_block_device.value, "volume_size", null)
volume_type = lookup(root_block_device.value, "volume_type", null)
}
}
想要使用 terraform 从 AMI 和具有 4 个卷的 AMI 旋转 ec2
那么你不需要做任何事情。 EBS 卷已经通过块储存设备映射关联到 AMI。 从该 AMI 启动的任何实例都将自动与 4 个 ebs 卷一起启动。
有关块设备映射的更多信息:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.