PropK
PropK

Reputation: 687

Modify Instance size instead of creating new volume (Cloudformation)

Im trying to give more disk space to my instance as by default it used 8GB. I need to be around 20GB. I use the following:

But i get this error - Invalid value '/dev/sda1' for unixDevice. Attachment point /dev/sda1 is already in use

Is there a way of modifying the disk space without creating a new Volume or am i doing something wrong?

"WebServerInstance": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
            "Volumes" : [ 
          { "VolumeId" : { "Ref" : "MyVolume1" },
            "Device" : "/dev/sda1"
          }
        ],
}
}
"MyVolume1": {
      "Type": "AWS::EC2::Volume",
      "Properties": {
        "Size": "50",
        "AvailabilityZone" : "eu-west-1a"
      },}

Upvotes: 1

Views: 1617

Answers (2)

John Rotenstein
John Rotenstein

Reputation: 269101

Updated in November 2020

As per the AWS::EC2::Volume documentation for the Size property:

Update requires: No interruption

Therefore, you can modify the template and then perform an Update.

Upvotes: 0

Brett Lester
Brett Lester

Reputation: 21

I have a couple of issues with John Rotenstein's answer. In fairness to John, AWS is rapidly evolving and his advice may have been correct/appropriate at the time.

  1. It is in fact possible to increase the size of an EBS volume via CloudFormation. However you can't reduce the size of an EBS volume via CloudFormation, or by any other means. If you increase the volume size, you will need to extend the volume in your OS, so that it sees the extra space.
  2. If you are managing your AWS resources via CloudFormation, modifying those resources in the Management Console creates configuration drift, which at best is untidy and at worst is dangerous. If you are adopting an infrastructure as code approach, you should always modify your resources in code.

Upvotes: 2

Related Questions