Skip to content

Instantly share code, notes, and snippets.

@RobBiddle
Last active December 16, 2020 00:11
Show Gist options
  • Save RobBiddle/bdc5b1f63ac6d14e30fc72a72667fec7 to your computer and use it in GitHub Desktop.
Save RobBiddle/bdc5b1f63ac6d14e30fc72a72667fec7 to your computer and use it in GitHub Desktop.
Save money with this PowerShell function to switch AWS EBS Volumes from gp2 to gp3 :-D
function Save-MoneyOnEBSStorage {
(Get-AWSCredential -ListProfileDetail).ProfileName | ForEach-Object {
$ThisProfile = $_
Get-EC2Volume -ProfileName $ThisProfile | `
Where-Object State -eq 'in-use' | `
Where-Object VolumeType -eq 'gp2' | `
ForEach-Object {
if ($_.Iops -gt 3000) {
$ThisIops = $_.Iops
}
else {
$ThisIops = 3000
}
Edit-EC2Volume -VolumeId $_.VolumeId -VolumeType gp3 -Iops $ThisIops -ProfileName $ThisProfile
}
}
}
Export-ModuleMember -Function Save-MoneyOnEBSStorage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment