Created
November 26, 2025 08:01
-
-
Save mu88/b1d0616163297f6190caea40657aee4b to your computer and use it in GitHub Desktop.
AWS Aurora OS maintenance
This file contains hidden or 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
| $ErrorActionPreference = "Stop" | |
| $PSNativeCommandUseErrorActionPreference = $true | |
| Clear-Host | |
| $pendingOsUpgradeResourceIdentifiers = @() | |
| $pendingMaintenanceActions = aws rds describe-pending-maintenance-actions | ConvertFrom-Json | |
| $pendingMaintenanceActions.PendingMaintenanceActions | ForEach-Object { | |
| $resourceIdentifier = $_.ResourceIdentifier | |
| $_.PendingMaintenanceActionDetails | ForEach-Object { | |
| $action = $_.Action | |
| $optInStatus = $_.OptInStatus | |
| $currentApplyDate = $_.CurrentApplyDate | |
| $description = $_.Description | |
| if (($action -ne "os-upgrade") -And ($action -ne "system-update")) { | |
| Write-Host "Skipping non-OS-patch action '$action' on resource '$resourceIdentifier'" | |
| return | |
| } | |
| if (($currentApplyDate -ne $null) -And ($currentApplyDate -gt (Get-Date)) -And ($optInStatus -eq "next-maintenance")) { | |
| Write-Host "Skipping action '$action' on resource '$resourceIdentifier' scheduled for next maintenance window on date '$currentApplyDate'" | |
| return | |
| } | |
| Write-Host "Detected pending maintenance action '$action' ('$description') on resource '$resourceIdentifier'" | |
| $pendingOsUpgradeResourceIdentifiers += @{ | |
| ResourceIdentifier = $resourceIdentifier | |
| Action = $action | |
| } | |
| } | |
| } | |
| if ($pendingOsUpgradeResourceIdentifiers.Count -eq 0) { | |
| Write-Host "No pending OS patches found." | |
| exit 0 | |
| } | |
| Write-Host "`nPending OS upgrade resource identifiers:`n$($pendingOsUpgradeResourceIdentifiers | Out-String)" | |
| Read-Host "Press Enter to continue with applying the pending OS patches..." | |
| $pendingOsUpgradeResourceIdentifiers | ForEach-Object { | |
| $resourceIdentifier = $_.ResourceIdentifier | |
| $action = $_.Action | |
| Write-Host "Applying pending maintenance action on resource '$resourceIdentifier'" | |
| aws rds apply-pending-maintenance-action --resource-identifier $resourceIdentifier --apply-action $action --opt-in-type next-maintenance | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment