Migrating to AWS EBS-GP3

This guide explains how to migrate Amazon Elastic Block Store (EBS) volumes from gp2 to gp3, highlighting gp3's improved performance, cost-effectiveness, and flexibility.

Benefits of Migrating to gp3:

  • Improved Performance:

    • Independent Performance Customization: Customize IOPS and throughput separately from volume size for more flexibility to meet workload needs, while enjoying higher baseline IOPS and throughput than gp2 volumes.
  • Cost Savings:

    • Pay for what you use: Only pay for the IOPS and throughput you actually use, which can significantly lower costs.
  • Enhanced Flexibility:

    • Dynamically adjust performance: Easily change IOPS and throughput as needed to match changing workload demands.

Migration Process:

  1. Assess Current Usage:

    • Evaluate your current gp2 volume usage, define the necessary IOPS and throughput for gp3, and estimate potential cost savings using the AWS gp3 pricing calculator.
  2. Plan and Test:

    • Create a Migration Plan: Develop a detailed plan for migrating volumes, including the sequence, potential downtime, and rollback strategies, and perform test migrations by moving a small number of volumes to gp3 in a non-production environment to ensure the process and application performance are validated.
  3. Modify Volumes:

    • Detach and Modify (for non-critical volumes): Detach the volume from the instance, change the volume type to gp3, and reattach it, while for critical volumes, modify the volume type to gp3 without detaching to minimize downtime, possibly needing a brief application pause.
  4. Monitor and Optimize:

    • Continuously monitor application performance, adjust IOPS and throughput settings for optimal performance and cost-effectiveness, and analyze EBS costs to ensure maximum savings after migration.

Verify the presence of GP2 EBS volumes in the AWS Account.

Create an IAM Role for the Lambda Function and grant the necessary permissions.

Create a Lambda function that identifies GP2 volumes and changes them to GP3.

Add the following code when creating the lambda function.

import boto3

ec2 = boto3.client('ec2')

def lambda_handler(event, context):
    volumes = ec2.describe_volumes(Filters=[{'Name': 'volume-type', 'Values': ['gp2']}])
    for volume in volumes['Volumes']:
        volume_id = volume['VolumeId']
        ec2.modify_volume(VolumeId=volume_id, VolumeType='gp3')
        print(f"Modified {volume_id} to gp3")

    return {"message": "EBS volumes updated successfully"}

Create a rule in Amazon EventBridge.

Click on schedules -> enter name ->schedule pattern ->Recurring schedule ->Rate-based schedule -> Enter Rate expression -> Flexible time window - > Min

Select target -> select AWS lambda ->In invoke -> select lambda function Setting -> permission -> use existing role And create a schedules.

Add your Lambda function as the target.

Run the Lambda function using a scheduler.

Verify the EBS Volume type.

#Troubleshooting

If you encounter an error while creating EventBridge, edit the role and update the code in the role.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "scheduler.amazonaws.com" 
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

By following these steps and best practices, you can migrate your EBS volumes from gp2 to gp3, boosting performance, lowering costs, and increasing the flexibility of your AWS workloads.

Happy Learning…!