In this hands-on guide, we’ll show you how you can migrate your EBS gp2 volumes to gp3 to lower your AWS disk costs by up to 20%.
General Purpose SSD (gp2) Amazon EBS volumes are a cost-effective way for AWS customers to access SSD performance for a variety of applications, such as virtual desktops, medium-sized databases, development, and testing environments. However, the performance of gp2 volumes is tied to their provisioned size, which increases linearly with the volume size. Increasing volume size comes with increased cost too. This can lead to over-provisioning of storage or performance, which is not cost-effective.
To address this issue, AWS introduced a new Amazon EBS General Purpose SSD volume type, gp3, in December 2020.
gp3 volumes provide predictable performance of 3,000 IOPS and 125 MiB/s, regardless of volume size.
Additionally, with gp3 volumes, customers can provision IOPS and throughput independently, without increasing storage size, at costs up to 20% less per GB compared to gp2 volumes. Furthermore, gp3 volumes can be scaled up to 16,000 IOPS and 1,000 MiB/s for an additional fee, making it 4 times faster than maximum throughput of gp2 volumes.
By migrating from gp2 volumes to gp3 volumes without restarting instances or detaching volumes, customers can achieve cost reduction on their monthly storage spend.
Here is a quick comparison of cost between gp2 and gp3 volumes in the us-east-1 (N. Virginia) Region (detailed pricing examples are available here):
You can download the EBS gp2 to gp3 migration cost savings calculator to find out how much you can save by migrating your EBS gp2 volumes to gp3.
So, let’s say you have 100 gp2 volumes having 100 GiB each, you could save up to $130 monthly by migrating from gp2 to gp3:
Migrating EBS volumes from gp2 to gp3 can be done via AWS console or AWS CLI without the need to restart your instances or detach your volumes.
Find and Migrate gp2 volumes via AWS Console
To modify an EBS volume using the console:
a. To modify the type, choose gp3 for Volume Type.
b. To modify the size, enter a new value for Size.
c. To modify the IOPS, enter a new value for IOPS.
d. To modify the throughput, if the volume type is gp3, enter a new value for Throughput.
Important notes:
1. Use the describe-volumes command with the --filters option to get a list of all gp2 volumes:
aws ec2 describe-volumes --filters "Name=volume-type,Values=gp2"
2. Use the modify-volume command so you migrate to gp3:
aws ec2 modify-volume --volume-type gp3 --volume-id <volume-id>
Where <volume-id> is the Volume ID that you want to migrate to gp3.
The following is an example command to modify a gp2 volume to gp3 and configure specific IOPS and throughput.
aws ec2 modify-volume --volume-type gp3 --iops 4000 --throughput 250 --volume-id <volume-id>
Here is a simple bash script that you can use to change all gp2 volumes to gp3 volumes using the AWS CLI:
#!/bin/bash
#Get all the gp2 volumes
GP2_VOLUMES=$(aws ec2 describe-volumes
--filters "Name=volume-type,Values=gp2" --query 'Volumes[*].{ID:VolumeId}')
#Loop through all the gp2 volumes
for volume in $(echo $GP2_VOLUMES | jq -r '.[] | @base64'); do
volume=$(echo $volume | base64 --decode)
VOLUME_ID=$(echo $volume | jq -r '.ID')
echo "Changing volume $VOLUME_ID to gp3"
#Change the volume type from gp2 to gp3
aws ec2 modify-volume --volume-id $VOLUME_ID --volume-type gp3
done
This script uses the AWS CLI command describe-volumes to get a list of all gp2 volumes, and then loops through them, changing the volume type from gp2 to gp3 using the modify-volume command. The script uses jq and base64 to parse the JSON output of the describe-volumes command.
Please note that this script will cause the default values for the IOPS (3000) and throughput (125 MB/s).
Additionally, I recommend that you first test it in a non-production environment, and make sure to take backups before running it.
With Stream.Security Architectural Standards you can easily find gp2 volumes to be migrated to gp3, using Stream's out-of-the-box EBS volumes Cost rules or you can create your own custom rules while using tags and various EBS volume attributes.
By using these capabilities, you can review the total predicted cost of each rule, and the breakdown of cost per violated resource within each rule.
Example architectural standard: Ensure EBS volumes are of type gp3 (General Purpose SSD) instead of gp2
This rule identifies EBS volumes of type gp2. Ensuring that your Amazon EC2 instances are using new General Purpose SSD volumes (gp3) instead of previous General Purpose SSD volumes (gp2) is best practice for cost-effective storage that fits a broad range of workloads.
This rule can help you work align better with the AWS Well-Architected Framework
This architectural standard’s conditions:
Review rule violations: When there are violations for this rule (or any rule in our architectural standards), this view shows each violated resource including the related predicted cost.
Additionally, Stream.Security’s out-of-the-box checks for Provisioned IOPS SSD volumes.
Using new General Purpose SSD (gp3) volumes instead of Provisioned IOPS (PIOPS) SSD is a good strategy for cutting down on AWS costs because for gp SSDs you only pay for the storage compared to PIOPS SSDs where you pay for both storage and IOPS. Converting existing PIOPS-based volumes to gp volumes is possible by configuring larger storage which gives higher baseline performance of IOPS for a lower cost.
Ensure EBS volumes are of type gp3 (General purpose SSD) instead of io1
This rule checks io1 volume type that you could potentially migrate to General Purpose SSD (gp3)
You can create your own custom rules using the rule creation wizard on Stream.Security.
Here’s a custom rule example:
The below custom rule checks for volumes type of gp2 with size greater than 100 and IOPS greater than 600, which are associated to a project called Lightlytics, by using the proper Tag filter.
This hands-on guide discussed how Amazon EBS gp3 volumes provide a cost-effective option by allowing independent configuration of storage and performance. Migrating from gp2 to gp3 volumes can result in significant cost savings, while also providing more customizable storage and IOPS options for your workload.
Migrating to gp3 volumes with the same size and performance settings as gp2 can be an easy way to reduce costs.
By monitoring EBS gp2 utilization and performance metrics, you can achieve even greater savings on storage costs by properly sizing storage.
Read Tal's previous blog posts in this series:
Reach out to Tal on LinkedIn if you'd like to suggest other topics, tips & tricks to reduce AWS cost.
Stream.Security delivers the only cloud detection and response solution that SecOps teams can trust. Born in the cloud, Stream’s Cloud Twin solution enables real-time cloud threat and exposure modeling to accelerate response in today’s highly dynamic cloud enterprise environments. By using the Stream Security platform, SecOps teams gain unparalleled visibility and can pinpoint exposures and threats by understanding the past, present, and future of their cloud infrastructure. The AI-assisted platform helps to determine attack paths and blast radius across all elements of the cloud infrastructure to eliminate gaps accelerate MTTR by streamlining investigations, reducing knowledge gaps while maximizing team productivity and limiting burnout.