Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I just increase the size of my root disk on AWS EC2 for use with Elastic Beanstalk?

On deployment I copy datafiles from S3 to my root drive to be used by Tomcat application. This is working perfectly, the trouble is the root disk is only 8GB and my datafiles will soon be larger than that. I want to increase the size of the root disk a little (15GB should be fine for another year) without moving to a larger more expensive EC2 instance, I'm currently using m3.medium.

As being used by EB I need the correct EC2 configuration to start as required, I cannot modify an already running instance by manually adding another disk. I'm using EB load balanced so instances may come and go to meet demand.

like image 930
Paul Taylor Avatar asked Jul 17 '14 12:07

Paul Taylor


1 Answers

This can be done using the following ebextension snippet.

Resources:
    AWSEBAutoScalingLaunchConfiguration:
        Type: AWS::AutoScaling::LaunchConfiguration
        Properties:
            BlockDeviceMappings:
               - DeviceName: /dev/sda1
                 Ebs:
                     VolumeSize:
                        15

Add this snippet to your app source in a file at path .ebextensions/01-change-root-volume-size.config. You can name the file whatever you want but it should be in the .ebextensions directory and should have a suffix of .config.

Update your environment with this new app source. This will terminate your current instance and start a new one with the size you desire.

Read more about customizing AWS Resources with Elastic Beanstalk here. More details on what other customizations you can do for the launchconfiguration are available here. More documentation on ebextensions here.

Another thing to remember is that /dev/sda1 works for m3.medium if you are using an HVM instance or GPU instance like c3.large, g2.2xlarge, i2.xlarge etc. then you will need to use DeviceName as /dev/xvda instead.

like image 177
Rohit Banga Avatar answered Sep 19 '22 01:09

Rohit Banga