Cla*_*dra 4 amazon-ec2 terraform
我没有找到在aws_launch_template和 terraform aws 中使用block_device_mappings覆盖根大小设备的方法。
我知道我可以指定一个额外的卷大小,例如:
block_device_mappings {
device_name = "/dev/xvda"
ebs {
volume_size = "${var.frontend_kong_volume_size}"
volume_type = "${var.frontend_kong_volume_type}"
delete_on_termination = "true"
}
}
Run Code Online (Sandbox Code Playgroud)
但是我在 VM 中获得了一个具有这些规格的新磁盘。但我想做的是调整根磁盘的大小。
你能帮我弄清楚怎么做吗?
谢谢。
block_device_mappings用于附加块设备。
您必须知道安装根设备的设备。例如对于centos 7 AMI,它是/dev/sda1
resource "aws_launch_template" "foobar" {
name_prefix = "foobar"
image_id = "ami-9887c6e7"
instance_type = "t2.micro"
block_device_mappings {
device_name = "/dev/sda1"
ebs {
volume_size = 40
}
}
}
resource "aws_autoscaling_group" "bar" {
availability_zones = ["us-east-1a"]
desired_capacity = 1
max_size = 1
min_size = 1
launch_template = {
id = "${aws_launch_template.foobar.id}"
version = "$$Latest"
}
}
Run Code Online (Sandbox Code Playgroud)
但请记住,terraform 中卷大小的更新不会对正在运行的实例生效。因此,您将不得不更换实例以增加卷大小。
归档时间: |
|
查看次数: |
5751 次 |
最近记录: |