AWS News Blog

New – Query for AWS Regions, Endpoints, and More Using AWS Systems Manager Parameter Store

Voiced by Polly

Update (August 8, 2021) – Added single quotes around the parameters passed to jq so that they are not processed by the shell.


In response to requests from AWS customers, I have been asking our service teams to find ways to make information about our regions and services available programmatically. Today I am happy to announce that this information is available in the AWS Systems Manager Parameter Store, and that you can easily access it from your scripts and your code. You can get a full list of active regions, find out which services are available with them, and much more.

Running Queries
I’ll use the AWS Command Line Interface (AWS CLI) for most of my examples; you can also use the AWS Tools for Windows PowerShell or any of the AWS SDKs. As is the case with all of the CLI commands, you can request output in JSON, tab-delimited text, or table format. I’ll use JSON, and will make liberal use of the jq utility to show the more relevant part of the output from each query.

Here’s how to query for the list of active regions:

$ aws ssm get-parameters-by-path \
  --path /aws/service/global-infrastructure/regions --output json | \
  jq '.Parameters[].Name'
"/aws/service/global-infrastructure/regions/ap-northeast-1"
"/aws/service/global-infrastructure/regions/eu-central-1"
"/aws/service/global-infrastructure/regions/eu-north-1"
"/aws/service/global-infrastructure/regions/eu-west-1"
"/aws/service/global-infrastructure/regions/eu-west-3"
"/aws/service/global-infrastructure/regions/sa-east-1"
"/aws/service/global-infrastructure/regions/us-east-2"
"/aws/service/global-infrastructure/regions/us-gov-east-1"
"/aws/service/global-infrastructure/regions/us-gov-west-1"
"/aws/service/global-infrastructure/regions/us-west-1"
"/aws/service/global-infrastructure/regions/ap-northeast-2"
"/aws/service/global-infrastructure/regions/ap-northeast-3"
"/aws/service/global-infrastructure/regions/ap-south-1"
"/aws/service/global-infrastructure/regions/ap-southeast-1"
"/aws/service/global-infrastructure/regions/ap-southeast-2"
"/aws/service/global-infrastructure/regions/ca-central-1"
"/aws/service/global-infrastructure/regions/cn-north-1"
"/aws/service/global-infrastructure/regions/cn-northwest-1"
"/aws/service/global-infrastructure/regions/eu-west-2"
"/aws/service/global-infrastructure/regions/us-west-2"
"/aws/service/global-infrastructure/regions/us-east-1"

Here’s how to display a complete list of all available AWS services, sort them into alphabetical order, and display the first 10 (out of 155, as I write this):

$ aws ssm get-parameters-by-path \
  --path /aws/service/global-infrastructure/services --output json | \
  jq '.Parameters[].Name' | sort | head -10
"/aws/service/global-infrastructure/services/acm"
"/aws/service/global-infrastructure/services/acm-pca"
"/aws/service/global-infrastructure/services/alexaforbusiness"
"/aws/service/global-infrastructure/services/apigateway"
"/aws/service/global-infrastructure/services/application-autoscaling"
"/aws/service/global-infrastructure/services/appmesh"
"/aws/service/global-infrastructure/services/appstream"
"/aws/service/global-infrastructure/services/appsync"
"/aws/service/global-infrastructure/services/athena"
"/aws/service/global-infrastructure/services/autoscaling"

Here’s how to get the list of services that are available in a given region (again, first 10, sorted):

$ aws ssm get-parameters-by-path \
  --path /aws/service/global-infrastructure/regions/us-east-1/services --output json | \
  jq '.Parameters[].Name' | sort | head -10
"/aws/service/global-infrastructure/regions/us-east-1/services/acm"
"/aws/service/global-infrastructure/regions/us-east-1/services/acm-pca"
"/aws/service/global-infrastructure/regions/us-east-1/services/alexaforbusiness"
"/aws/service/global-infrastructure/regions/us-east-1/services/apigateway"
"/aws/service/global-infrastructure/regions/us-east-1/services/application-autoscaling"
"/aws/service/global-infrastructure/regions/us-east-1/services/appmesh"
"/aws/service/global-infrastructure/regions/us-east-1/services/appstream"
"/aws/service/global-infrastructure/regions/us-east-1/services/appsync"
"/aws/service/global-infrastructure/regions/us-east-1/services/athena"
"/aws/service/global-infrastructure/regions/us-east-1/services/autoscaling"

Here’s how to get the list of regions where a service (Amazon Athena, in this case) is available:

$ aws ssm get-parameters-by-path \
  --path /aws/service/global-infrastructure/services/athena/regions --output json | \
  jq '.Parameters[].Value'
"ap-northeast-2"
"ap-south-1"
"ap-southeast-2"
"ca-central-1"
"eu-central-1"
"eu-west-1"
"eu-west-2"
"us-east-1"
"us-east-2"
"us-gov-west-1"
"ap-northeast-1"
"ap-southeast-1"
"us-west-2"

Here’s how to use the path to get the name of a service:

$ aws ssm get-parameters-by-path \
  --path /aws/service/global-infrastructure/services/athena --output json | \
  jq '.Parameters[].Value'
"Amazon Athena"

And here’s how you can find the regional endpoint for a given service, again using the path:

$ aws ssm get-parameter \
  --name /aws/service/global-infrastructure/regions/us-west-1/services/s3/endpoint \
  --output json | \
  jq '.Parameter.Value'
"s3.us-west-1.amazonaws.com"

Available Now
This data is available now and you can start using it today at no charge.

Jeff;

PS – Special thanks to my colleagues Blake Copenhaver and Phil Cali for their help with this post!

 

Jeff Barr

Jeff Barr

Jeff Barr is Chief Evangelist for AWS. He started this blog in 2004 and has been writing posts just about non-stop ever since.