I dont find a way to override root size device using block_device_mappings in aws_launch_template with terraform aws.
I know I can specify an extra volume size doing for example:
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"
}
}
but I get a new disk in the VM with those specifications. But what I want to do is resize the root disk.
Can you help me to figure out how to do it?
Thanks.
block_device_mappings is for additional block devices.
You have to know device where root device mounted. for example for centos 7 AMI it's /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"
}
}
But remember that update of volume size in terraform will not take effect to running instances. So you will have to replace instances to increase volume size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With