-
Notifications
You must be signed in to change notification settings - Fork 0
/
ebs-gp2-to-gp3-conversion
23 lines (21 loc) · 1.07 KB
/
ebs-gp2-to-gp3-conversion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Script for converting gp2 volumes to gp3 volumes.
import boto3
def convert_gp2_to_gp3(volume_ids):
ec2 = boto3.client('ec2')
for volume_id in volume_ids:
try:
response = ec2.modify_volume(
VolumeId = volume_id,
VolumeType = 'gp3',
)
print(f"Volume {volume_id} conversion to gp3 initiated: {response}")
except ec2.exceptions.ClientError as e:
if e.response['Error']['Code'] == 'InvalidParameterValue':
print(f"Volume {volume_id} is not of type gp2. No conversion needed.")
else:
print(f"Error converting volume {volume_id} to gp3: {e}")
# Add IDs of the volumes you want to convert
volume_ids_to_convert = ['', '']
# Convert the specified volumes from gp2 to gp3
convert_gp2_to_gp3(volume_ids_to_convert)
#A variation of this script could be used in an automated pipeline to update volumes from Amazon EBS gp2 to Amazon EBS gp3. However, changes should also be made to existing IAC and deployment pipelines to ensure that all new volumes are provisioned as gp3.