Skip to content

fix: guard against null backup costs in GovCloud#122

Open
mtellin wants to merge 1 commit into
masterfrom
fix/govcloud-backup-costs-null
Open

fix: guard against null backup costs in GovCloud#122
mtellin wants to merge 1 commit into
masterfrom
fix/govcloud-backup-costs-null

Conversation

@mtellin

@mtellin mtellin commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Initializes $backupTotalNetUnblendedCost to 0 so the summary line doesn't show blank when Cost Explorer is unavailable
  • Adds Where-Object { $null -ne $_ } filter before TrimStart('$') to prevent null reference crash
  • Adds $backupCostsList.Count -eq 0 check alongside the existing null check for robustness

The Cost Explorer endpoint (ce.<region>.amazonaws.com) doesn't exist in all GovCloud regions, causing the script to crash with "You cannot call a method on a null-valued expression" when it tries to parse cost strings.

Closes #80

Test plan

  • Run Get-AWSSizingInfo.ps1 -Partition GovCloud against an account with access to us-gov-west-1 and us-gov-east-1
  • Verify script completes without crash when CE is unavailable in a region
  • Confirm cost summary shows $0 instead of crashing or showing blank

🤖 Generated with Claude Code

Cost Explorer endpoints don't exist in all GovCloud regions, causing
null AWSBackupNetUnblendedCost values that crash on TrimStart('$').
Adds a null filter before decimal conversion and initializes the
total to 0 so the summary line renders cleanly when no cost data
is available.

Closes #80

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Running the script on GovCloud resutls in errors with BackupPlans

1 participant