Last active
April 12, 2022 15:58
-
-
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.
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 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