Home > Net >  How to get list of available AWS services in a region from boto3 call
How to get list of available AWS services in a region from boto3 call

Time:04-28

I want to use boto3 to get list of available aws services in a specific region. Is there any way to do this. I tried using Session object:

session = boto3.Session(region_name='ap-south-1').get_available_services()

but it is giving me all the AWS services. For eg: Cloudsearch is not present in ap-south-1, but this function still gives me the service in the output. Also, I don't want to use ssm service get_parameters_by_path function as I don't want to give ssm permission. Any other way?

CodePudding user response:

To be frank, I reckon, your best bet actually is the Systems Manager Parameter Store.

For example, you can easily display a complete list of all available AWS services, sort them into alphabetical order, and, for the brevity, show the first 10.

$ aws ssm get-parameters-by-path \
  --path /aws/service/global-infrastructure/services --output json | \
  jq '.Parameters[].Name' | sort | head -10

Output:

"/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"

And here's how to get the list of services that are available in a given region. Show first 10 and 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

But... if you want any other way you might want to try AWS Price List API.

With the AWS Price List Query API, you can query specific information about AWS services, products, and pricing using an AWS SDK or the AWS CLI.

This obviously can be narrowed down to a specific region. If there's a price, there is a service.

CodePudding user response:

I got this by below code:

resp = boto3.Session().get_available_regions('cloudsearch')

This gave me the list of all the regions where cloudsearch service is available.

  • Related