Skip to main content

Simple Python library that converts between cloud region names across AWS/Azure/GCP.

Project description

cloudregion

PyPI version Python versions Release Build status codecov License

A lightweight Python library for canonical cloud region mapping across AWS, Azure, and Google Cloud Platform.

Tired of remembering that AWS uses us-east-1, Azure uses eastus, and GCP uses us-east1 for the same region? cloudregion provides a simple, consistent interface using intuitive city-based names.

🚀 Quick Start

pip install cloudregion
from cloudregion import region

# Use intuitive city names
r = region('virginia')
print(r.aws)    # us-east-1
print(r.azure)  # eastus
print(r.gcp)    # us-east1

# Works with aliases too
region('us-east').aws   # us-east-1
region('eu-west').gcp   # europe-west1

💡 Why cloudregion?

Multi-cloud developers waste time dealing with inconsistent region naming. Each cloud provider uses different conventions:

Region AWS Azure GCP
US East us-east-1 eastus us-east1
US West us-west-2 westus2 us-west1
EU West eu-west-1 northeurope europe-west1

This forces developers to:

  • 🔄 Maintain separate region mappings in code
  • 🧠 Remember provider-specific names for equivalent regions
  • 📝 Update configuration files for each cloud provider
  • 🔧 Write cloud-specific code instead of cloud-agnostic code

🎯 Features

  • 🏙️ City-based names: Use intuitive names like virginia, tokyo, frankfurt
  • 🔄 Multi-cloud: Single interface for AWS, Azure, and GCP
  • 🏷️ Smart aliases: us-east, eu-west, asia-southeast work too
  • 🧰 SDK integration: Helper functions for boto3, Azure SDK, GCP clients
  • ✅ Type safe: Full mypy support with proper type hints
  • ⚡ Zero dependencies: Pure Python with no external requirements
  • 🧪 Well tested: Comprehensive test suite with 100% coverage

📖 Usage

Basic Usage

from cloudregion import region

# Create region objects
virginia = region('virginia')
tokyo = region('tokyo')
frankfurt = region('frankfurt')

# Access provider-specific names
print(virginia.aws)    # us-east-1
print(tokyo.azure)     # japaneast
print(frankfurt.gcp)   # europe-west3

# Use aliases
us_east = region('us-east')      # resolves to virginia
eu_west = region('eu-west')      # resolves to dublin
asia = region('asia-southeast')  # resolves to singapore

SDK Integration

from cloudregion.integrations import boto3_client_kwargs, azure_credential_kwargs, gcp_client_kwargs

# AWS boto3
import boto3
client_config = boto3_client_kwargs('ec2', 'virginia')
ec2 = boto3.client(**client_config)  # auto-resolves to us-east-1

# Azure
azure_config = azure_credential_kwargs('frankfurt', subscription_id='my-sub')
# Use with Azure SDK clients

# GCP
gcp_config = gcp_client_kwargs('tokyo', project='my-project')
# Use with Google Cloud client libraries

Error Handling

from cloudregion import region, UnknownRegionError

try:
    r = region('unknown-place')
except UnknownRegionError as e:
    print(f"Error: {e}")
    # Error: Unknown region 'unknown-place'. Available regions: virginia, oregon, ...

🗺️ Supported Regions

Canonical Name AWS Azure GCP
virginia us-east-1 eastus us-east1
ohio us-east-2 eastus2 us-east4
oregon us-west-2 westus2 us-west1
california us-west-1 westus us-west2
toronto ca-central-1 canadacentral northamerica-northeast1
dublin eu-west-1 northeurope europe-west1
london eu-west-2 uksouth europe-west2
paris eu-west-3 francecentral europe-west9
frankfurt eu-central-1 germanywestcentral europe-west3
stockholm eu-north-1 swedencentral europe-north1
singapore ap-southeast-1 southeastasia asia-southeast1
sydney ap-southeast-2 australiaeast australia-southeast1
tokyo ap-northeast-1 japaneast asia-northeast1
seoul ap-northeast-2 koreacentral asia-northeast3
mumbai ap-south-1 centralindia asia-south1
hong-kong ap-east-1 eastasia asia-east2

Aliases

Common aliases are supported for convenience:

  • us-eastvirginia
  • us-westoregon
  • eu-westdublin
  • eu-centralfrankfurt
  • asia-southeastsingapore
  • asia-northeasttokyo

🛠️ Development

# Clone the repository
git clone https://github.com/prassanna-ravishankar/cloudregion.git
cd cloudregion

# Install development dependencies
uv sync --dev

# Run tests
uv run pytest

# Run type checking
uv run mypy cloudregion/

# Run linting
uv run ruff check .

# Format code
uv run ruff format .

📋 Requirements

  • Python 3.9+
  • No external dependencies

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. See our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🔮 Roadmap

  • Terraform/Pulumi integration: Generate provider-specific variables
  • Compliance zones: EU, US-Gov, China region mappings
  • Latency data: Distance and performance metrics between regions
  • Service availability: Which services are available in each region
  • Cost data: Regional pricing information integration

🙏 Acknowledgments

  • Inspired by the need for simpler multi-cloud development
  • Built with modern Python tooling (uv, ruff, mypy)
  • Tested across Python 3.9-3.13

Made with ❤️ for multi-cloud developers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudregion-0.0.3.tar.gz (59.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloudregion-0.0.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file cloudregion-0.0.3.tar.gz.

File metadata

  • Download URL: cloudregion-0.0.3.tar.gz
  • Upload date:
  • Size: 59.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for cloudregion-0.0.3.tar.gz
Algorithm Hash digest
SHA256 9f610add92f4d1a55e17991c01fbe1b392f8e5a05ff2e16a67b1f991ac2e9e4d
MD5 2bd4f8f6fefe278823a1bf2f410bdbd8
BLAKE2b-256 ff7c36ebe0e651a90c6d13342894c8f3b029bd051065cc6b33f1486495f5dc32

See more details on using hashes here.

File details

Details for the file cloudregion-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudregion-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b5edd35cf01b4a27cf1187004ba57d80fb95d414d7ac17efed4fd7ef8147958f
MD5 531ff643e7b4990b3ff768d9464e93fb
BLAKE2b-256 49bf2012c8e80f639a50c13b73a03ff81969a19ccc13930b33822dc86f47ef50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page