Skip to content

A package for retrieving a list of available regions from AWS.

License

Notifications You must be signed in to change notification settings

AWSToolbox/get-aws-regions-package

Repository files navigation

AWSToolbox logo
Github Build Status License Created
Release Released Commits since release

Overview

This module provides a simple method for retrieving and processing AWS region information. This is a core component for all of the tools in our AWS Toolbox.

Features

  • Fetching AWS Regions:

    • Retrieve a list of all AWS regions, optionally including/excluding regions based on account opt-in status.
    • Supports fetching detailed information about each region.
  • Region Details:

    • Fetch geographical location descriptions for specific AWS regions from the AWS Systems Manager (SSM) Parameter Store.
    • Utilizes concurrent threading for enhanced performance when fetching multiple region details.
  • Filtering:

    • Apply include and exclude filters to customize the list of AWS regions returned.

Functions

Public Functions

  • get_region_list
    • Retrieves a list of AWS regions.
    • Parameters:
      • include_list: Optional list of regions to include.
      • exclude_list: Optional list of regions to exclude.
      • all_regions: Boolean flag to include all regions (default: True).
      • details: Boolean flag to return detailed information about each region (default: False).
      • profile_name: String to specify the name of the profile to use.
    • Returns:
      • If details=True: Sorted list of dictionaries containing detailed region information.
      • If details=False: Sorted list of region names as strings.
    • Raises:
      • RegionListingError: If an error occurs during region retrieval or processing.

Usage

This module is designed to be used as part of the wolfsoftware.get-aws-regions package. The primary function, get_region_list, allows flexible retrieval and customization of AWS region information based on user-defined criteria.

Example

from wolfsoftware.get_aws_regions import get_region_list

# Example usage: Retrieve all regions and print their names
regions = get_region_list(details=False)
print("AWS Regions:", regions)

# Example usage: Retrieve detailed information for selected regions
detailed_regions = get_region_list(include_list=['us-west-1', 'us-east-1'], details=True)
for region in detailed_regions:
    print(f"Region: {region['RegionName']}, Location: {region['GeographicalLocation']}")

Notes

  • Ensure AWS credentials are properly configured for API access.
  • Error handling is integrated to manage exceptions during AWS operations.
  • Threading is utilized for efficient concurrent operations when fetching region details.

For further details and customization options, refer to the function docstrings and the module's implementation.