Skip to content

Instantly share code, notes, and snippets.

@austoonz
Last active April 12, 2022 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austoonz/073541661358306e8e48f4b694da7637 to your computer and use it in GitHub Desktop.
Save austoonz/073541661358306e8e48f4b694da7637 to your computer and use it in GitHub Desktop.
Sample PowerShell function to identify the closest AWS Region using AWS Service Endpoints.
function Get-AWSRegionLatency {
param (
[ValidateSet('dynamodb')]
[String] $ServiceForMeasurement = 'dynamodb'
)
$endpoints = [System.Collections.ArrayList]::new()
$regions = (Get-AWSRegion | Where-Object {$_.Region -notlike 'us-iso*'}).Region
foreach ($region in $regions) {
$null = $endpoints.Add(('{0}.{1}.amazonaws.com' -f $ServiceForMeasurement, $region))
}
Invoke-FastPing -HostName $endpoints
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment