title: update the size of EBS volume without replacing the older volume and rebooting the EC2 instance
body: <p>I am creating the EC2 instance and multiple EBS volumes with different sizes. Below terraform script is given for creating the same.</p>
  <pre><code>resource &quot;aws_ebs_volume&quot; &quot;ebs_volume&quot; {
    for_each = {
      0 = var.influxdb_data_volume_size
      1 = var.influxdb_wal_volume_size
      2 = var.telegraf_volume_size
      3 = var.grafana_volume_size
      4 = var.data_volume_size
    }
    availability_zone = var.availability_zone
    size              = each.value
    type              = &quot;gp2&quot;
    tags = {
      name = &quot;${var.tag}-ebs-volume&quot;
      billing = var.tag
    }
  }
  
  # section for the EBS volume attachment
  
  resource &quot;aws_volume_attachment&quot; &quot;volume_attachement&quot; {
    count       = var.ebs_volume_count
    volume_id   = aws_ebs_volume.ebs_volume[count.index].id
    device_name = &quot;${element(var.ec2_device_names, count.index)}&quot;
    instance_id = aws_instance.ec2_production.id
  }
  
  # section for the aws_key_pair 
  resource &quot;aws_key_pair&quot; &quot;key_pair&quot; {
    key_name   = &quot;${var.tag}-key-pair&quot;
    public_key = var.key_pair
    tags = {
      name = &quot;${var.tag}-key-pair&quot;
      billing = var.tag
    }
  
  }
  resource &quot;aws_instance&quot; &quot;ec2_production&quot; {
    # count         = &quot;${var.ec2_instance_count}&quot;
    ami           = var.ami
    availability_zone = var.availability_zone
    instance_type =  var.ec2_instance_type
    subnet_id = aws_subnet.subnet.id
    associate_public_ip_address = true
    vpc_security_group_ids = [aws_security_group.security_group_access_internet.id]
    # disable_api_termination = true
    key_name = &quot;${var.tag}-key-pair&quot;
    ebs_block_device {
      device_name = &quot;/dev/sda1&quot;
      volume_type = &quot;gp2&quot;
      volume_size = var.root_volume_size
    }
    tags = {
      name = &quot;${var.tag}-ec2&quot;
      billing = var.tag
    }
  }
  </code></pre>
  <p>The volume defined in <strong>aws_instance</strong> resource is the root volume having size of 40GB and I am creating multiple volumes of different sizes in <strong>aws_ebs_volume</strong> resource.</p>
  <p>Now I am trying to change the size of the root volume from 40GB to 60GB by updating the variable.tf file.</p>
  <p>When I am using the command <strong>terraform plan</strong> it's creating 6 resources and destroying 6 resources which include the EBS volumes and EC2 instance.</p>
  <p>Now, I want to increase the size of any volume which is root or any other which recreating or destroying anything.</p>
  <p>Below I am giving output of <strong>terraform plan</strong></p>
  <pre><code>-/+ resource &quot;aws_instance&quot; &quot;ec2_production&quot; {
        ~ arn                                  = &quot;arn:aws:ec2:us-west-1:666268854852:instance/i-0ac516fab494df462&quot; -&gt; (known after apply)
        ~ cpu_core_count                       = 1 -&gt; (known after apply)
        ~ cpu_threads_per_core                 = 1 -&gt; (known after apply)
        - disable_api_termination              = false -&gt; null
        - ebs_optimized                        = false -&gt; null
        - hibernation                          = false -&gt; null
        + host_id                              = (known after apply)
        ~ id                                   = &quot;i-0ac516fab494df462&quot; -&gt; (known after apply)
        ~ instance_initiated_shutdown_behavior = &quot;stop&quot; -&gt; (known after apply)
        ~ instance_state                       = &quot;running&quot; -&gt; (known after apply)
        ~ ipv6_address_count                   = 0 -&gt; (known after apply)
        ~ ipv6_addresses                       = [] -&gt; (known after apply)
        - monitoring                           = false -&gt; null
        + outpost_arn                          = (known after apply)
        + password_data                        = (known after apply)
        + placement_group                      = (known after apply)
        ~ primary_network_interface_id         = &quot;eni-0fd71c3a3e41237be&quot; -&gt; (known after apply)
        ~ private_dns                          = &quot;ip-10-0-16-27.us-west-1.compute.internal&quot; -&gt; (known after apply)
        ~ private_ip                           = &quot;10.0.16.27&quot; -&gt; (known after apply)
        + public_dns                           = (known after apply)
        ~ public_ip                            = &quot;13.56.209.171&quot; -&gt; (known after apply)
        ~ secondary_private_ips                = [] -&gt; (known after apply)
        ~ security_groups                      = [] -&gt; (known after apply)
          tags                                 = {
              &quot;billing&quot; = &quot;att&quot;
              &quot;name&quot;    = &quot;ec2&quot;
          }
        ~ tenancy                              = &quot;default&quot; -&gt; (known after apply)
          # (10 unchanged attributes hidden)
  
        - credit_specification {
            - cpu_credits = &quot;standard&quot; -&gt; null
          }
  
        - ebs_block_device { # forces replacement
            - delete_on_termination = false -&gt; null
            - device_name           = &quot;/dev/sdf&quot; -&gt; null
            - encrypted             = false -&gt; null
            - iops                  = 300 -&gt; null
            - tags                  = {
                - &quot;billing&quot; = &quot;att&quot;
                - &quot;name&quot;    = &quot;volume&quot;
              } -&gt; null
            - throughput            = 0 -&gt; null
            - volume_id             = &quot;vol-08569e15ccd8f1aad&quot; -&gt; null
            - volume_size           = 100 -&gt; null
            - volume_type           = &quot;gp2&quot; -&gt; null
          }
        - ebs_block_device { # forces replacement
            - delete_on_termination = false -&gt; null
            - device_name           = &quot;/dev/sdg&quot; -&gt; null
            - encrypted             = false -&gt; null
            - iops                  = 150 -&gt; null
            - tags                  = {
                - &quot;billing&quot; = &quot;att&quot;
                - &quot;name&quot;    = &quot;volume&quot;
              } -&gt; null
            - throughput            = 0 -&gt; null
            - volume_id             = &quot;vol-0e8c7cd7830fa2e02&quot; -&gt; null
            - volume_size           = 50 -&gt; null
            - volume_type           = &quot;gp2&quot; -&gt; null
          }
        - ebs_block_device { # forces replacement
            - delete_on_termination = false -&gt; null
            - device_name           = &quot;/dev/sdh&quot; -&gt; null
            - encrypted             = false -&gt; null
            - iops                  = 100 -&gt; null
            - tags                  = {
                - &quot;billing&quot; = &quot;att&quot;
                - &quot;name&quot;    = &quot;volume&quot;
              } -&gt; null
            - throughput            = 0 -&gt; null
            - volume_id             = &quot;vol-0f989100daa275774&quot; -&gt; null
            - volume_size           = 20 -&gt; null
            - volume_type           = &quot;gp2&quot; -&gt; null
          }
        - ebs_block_device { # forces replacement
            - delete_on_termination = false -&gt; null
            - device_name           = &quot;/dev/sdi&quot; -&gt; null
            - encrypted             = false -&gt; null
            - iops                  = 100 -&gt; null
            - tags                  = {
                - &quot;billing&quot; = &quot;att&quot;
                - &quot;name&quot;    = &quot;volume&quot;
              } -&gt; null
            - throughput            = 0 -&gt; null
            - volume_id             = &quot;vol-03cd5be3fea05aa45&quot; -&gt; null
            - volume_size           = 20 -&gt; null
            - volume_type           = &quot;gp2&quot; -&gt; null
          }
        - ebs_block_device { # forces replacement
            - delete_on_termination = false -&gt; null
            - device_name           = &quot;/dev/sdj&quot; -&gt; null
            - encrypted             = false -&gt; null
            - iops                  = 150 -&gt; null
            - tags                  = {
                - &quot;billing&quot; = &quot;att&quot;
                - &quot;name&quot;    = &quot;volume&quot;
              } -&gt; null
            - throughput            = 0 -&gt; null
            - volume_id             = &quot;vol-023e380eebbf2c91f&quot; -&gt; null
            - volume_size           = 50 -&gt; null
            - volume_type           = &quot;gp2&quot; -&gt; null
          }
        + ebs_block_device { # forces replacement
            + delete_on_termination = true
            + device_name           = &quot;/dev/sda1&quot;
            + encrypted             = (known after apply)
            + iops                  = (known after apply)
            + kms_key_id            = (known after apply)
            + snapshot_id           = (known after apply)
            + throughput            = (known after apply)
            + volume_id             = (known after apply)
            + volume_size           = 60
            + volume_type           = &quot;gp2&quot;
          }
  
        ~ enclave_options {
            ~ enabled = false -&gt; (known after apply)
          }
  
        + ephemeral_block_device {
            + device_name  = (known after apply)
            + no_device    = (known after apply)
            + virtual_name = (known after apply)
          }
  
        ~ metadata_options {
            ~ http_endpoint               = &quot;enabled&quot; -&gt; (known after apply)
            ~ http_put_response_hop_limit = 1 -&gt; (known after apply)
            ~ http_tokens                 = &quot;optional&quot; -&gt; (known after apply)
          }
  
        + network_interface {
            + delete_on_termination = (known after apply)
            + device_index          = (known after apply)
            + network_interface_id  = (known after apply)
          }
  
        ~ root_block_device {
            ~ delete_on_termination = true -&gt; (known after apply)
            ~ device_name           = &quot;/dev/sda1&quot; -&gt; (known after apply)
            ~ encrypted             = false -&gt; (known after apply)
            ~ iops                  = 120 -&gt; (known after apply)
            + kms_key_id            = (known after apply)
            ~ tags                  = {} -&gt; (known after apply)
            ~ throughput            = 0 -&gt; (known after apply)
            ~ volume_id             = &quot;vol-054112f2f104ff54e&quot; -&gt; (known after apply)
            ~ volume_size           = 40 -&gt; (known after apply)
            ~ volume_type           = &quot;gp2&quot; -&gt; (known after apply)
          }
      }
  
    # aws_volume_attachment.volume_attachement[0] must be replaced
  -/+ resource &quot;aws_volume_attachment&quot; &quot;volume_attachement&quot; {
        ~ id          = &quot;vai-1464807002&quot; -&gt; (known after apply)
        ~ instance_id = &quot;i-0ac516fab494df462&quot; -&gt; (known after apply) # forces replacement
          # (2 unchanged attributes hidden)
      }
  
    # aws_volume_attachment.volume_attachement[1] must be replaced
  -/+ resource &quot;aws_volume_attachment&quot; &quot;volume_attachement&quot; {
        ~ id          = &quot;vai-3274211254&quot; -&gt; (known after apply)
        ~ instance_id = &quot;i-0ac516fab494df462&quot; -&gt; (known after apply) # forces replacement
          # (2 unchanged attributes hidden)
      }
  
    # aws_volume_attachment.volume_attachement[2] must be replaced
  -/+ resource &quot;aws_volume_attachment&quot; &quot;volume_attachement&quot; {
        ~ id          = &quot;vai-1831356480&quot; -&gt; (known after apply)
        ~ instance_id = &quot;i-0ac516fab494df462&quot; -&gt; (known after apply) # forces replacement
          # (2 unchanged attributes hidden)
      }
  
    # aws_volume_attachment.volume_attachement[3] must be replaced
  -/+ resource &quot;aws_volume_attachment&quot; &quot;volume_attachement&quot; {
        ~ id          = &quot;vai-374757704&quot; -&gt; (known after apply)
        ~ instance_id = &quot;i-0ac516fab494df462&quot; -&gt; (known after apply) # forces replacement
          # (2 unchanged attributes hidden)
      }
  
    # aws_volume_attachment.volume_attachement[4] must be replaced
  -/+ resource &quot;aws_volume_attachment&quot; &quot;volume_attachement&quot; {
        ~ id          = &quot;vai-3725815030&quot; -&gt; (known after apply)
        ~ instance_id = &quot;i-0ac516fab494df462&quot; -&gt; (known after apply) # forces replacement
          # (2 unchanged attributes hidden)
      }
  
  Plan: 6 to add, 0 to change, 6 to destroy.
  </code></pre>
  <p>is there any way to achieve to update the volume size without destroying anything?</p>