Last active
December 16, 2020 00:11
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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