Last active
April 1, 2023 17:16
-
-
Save bluPhy/aeada8fb78743b59ae9943c6c94e0aa0 to your computer and use it in GitHub Desktop.
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
| ######################################################################################## | |
| # This will list all API names and regional enpoints for all AWS regions # | |
| # querying all regions also allow us to get the list of services available per region # | |
| ######################################################################################## | |
| Function Get-AWSModule { | |
| Param([string]$name) | |
| if (-not(Get-Module -Name $name)) { | |
| if (Get-Module -ListAvailable | Where-Object { $_.name -eq $name }) { | |
| Import-Module -Name $name | |
| $true | |
| } #end if module available then import | |
| else { $false } #module not available | |
| } # end if not module | |
| else { $true } #module already loaded | |
| } #end function get-AWSModule | |
| Get-AWSmodule -name “AWSPowerShell.NetCore” | |
| # get the endpoint for a service in a region | |
| Function Get-AWSServiceEndpoint { | |
| Param([string]$ServiceName, [string]$AWSRegion) | |
| Try { Get-SSMParameter -Name /aws/service/global-infrastructure/regions/$AWSRegion/services/$ServiceName/endpoint | Select-Object @{Expression = { $_.Value }; Label = "EndPoint" } } | |
| Catch {} | |
| } #end function Get-AWSServiceEndpoint | |
| $ResultWithItems = $null | |
| $ResultWithItems = @() | |
| # Get services | |
| $Services = (Get-SSMParametersByPath -Path /aws/service/global-infrastructure/services | Select-Object @{Expression = { $_.Value }; Label = "Service" }) | Sort-Object -Property service | |
| # Get the list of regions | |
| $Regions = (Get-SSMParametersByPath -Path /aws/service/global-infrastructure/regions | | |
| Select-Object @{Expression = { $_.Value }; Label = "Region" }) | Sort-Object -Property Region | |
| $Regions | ForEach-Object -Process { | |
| $Region = $_.Region | |
| Write-Host "Listing region:" $Region | |
| $Services | ForEach-Object -Process { | |
| $Service = $_.Service | |
| $EndPoint = (Get-AWSServiceEndpoint -ServiceName $Service -AWSRegion $Region).EndPoint | |
| Try { $API_Value = $EndPoint.Split(".")[0] } Catch { $API_Value = "-" } | |
| $Result = New-Object -TypeName System.Object | |
| $Result | Add-Member -MemberType NoteProperty -Name "Region" -Value $Region | |
| $Result | Add-Member -MemberType NoteProperty -Name "Service" -Value $Service | |
| $Result | Add-Member -MemberType NoteProperty -Name "API_Name" -Value $API_Value | |
| $Result | Add-Member -MemberType NoteProperty -Name "EndPoint" -Value $EndPoint | |
| $ResultWithItems += $Result | |
| } | |
| } | |
| $ResultWithItems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment