[Terraform] how to change EC2 default EBS to specified volume size

This is how to set the default 8GB EBS of EC2 to the specified size.

The version is as follows.

Terraform v0.12.25 
+ provider.aws v3.5.0

You can change it in root_block_device.
In the example below, it is changed to 100GB.

resource "aws_instance" "test" {
 ami = "ami-0d09d67328197c99" #centos7
 instance_type = "t3a.medium"
 vpc_security_group_ids = aws_security_group.test.id
 subnet_id = aws_subnet.test.id
 key_name = aws_key_pair.test.id
 root_block_device {
   volume_type = "gp2" 
   volume_size = 100
 tags = {
   Name = "test"

Please note that if you have already built EC2, the instance will be replaced.


Please share this page: