How to get the list of all registries present in an AWS account using Boto3

In this article, we will see how a user can get the list of all registries present in an AWS account using the boto3 library in Python.

What are AWS Glue Registries?

AWS Glue registries are containers for schema versions in the AWS Glue Schema Registry. They help organize and manage schemas for data serialization and deserialization across different services.

Prerequisites

  • AWS credentials configured (AWS CLI, environment variables, or IAM roles)

  • boto3 library installed: pip install boto3

  • Appropriate IAM permissions for AWS Glue operations

Approach to List Registries

  • Step 1: Import boto3 and botocore.exceptions to handle exceptions

  • Step 2: Create an AWS session using boto3 library with proper region configuration

  • Step 3: Create an AWS client for glue service

  • Step 4: Use the list_registries() method to fetch all available registries

  • Step 5: Handle exceptions appropriately

Example Code

The following code demonstrates how to fetch the list of all registries ?

import boto3
from botocore.exceptions import ClientError

def list_of_registries():
    session = boto3.session.Session()
    glue_client = session.client('glue')
    try:
        registries_data = glue_client.list_registries()
        return registries_data
    except ClientError as e:
        raise Exception("boto3 client error in list_of_registries: " + str(e))
    except Exception as e:
        raise Exception("Unexpected error in list_of_registries: " + str(e))

# Call the function
print(list_of_registries())

Sample Output

The output returns a dictionary containing registry information ?

{
    'Registries': [
        {
            'RegistryName': 'employee_details',
            'RegistryArn': 'arn:aws:glue:us-east-1:123456789012:registry/employee_details',
            'Description': 'Registry for employees record',
            'Status': 'AVAILABLE',
            'CreatedTime': '2024-01-15T10:30:00.000Z',
            'UpdatedTime': '2024-01-15T10:30:00.000Z'
        },
        {
            'RegistryName': 'security_details',
            'RegistryArn': 'arn:aws:glue:us-east-1:123456789012:registry/security_details',
            'Description': 'Registry for security record',
            'Status': 'AVAILABLE',
            'CreatedTime': '2024-01-10T09:15:00.000Z',
            'UpdatedTime': '2024-01-10T09:15:00.000Z'
        }
    ],
    'NextToken': 'string',
    'ResponseMetadata': {
        'RequestId': 'abc123-def456-ghi789',
        'HTTPStatusCode': 200
    }
}

Key Points

  • The list_registries() method returns only registries with status AVAILABLE

  • Registries with status DELETING are not included in the response

  • If no registries exist, the response contains an empty Registries list

  • The method supports pagination using the NextToken parameter for large datasets

Enhanced Version with Error Handling

Here's an improved version with better error handling and optional parameters ?

import boto3
from botocore.exceptions import ClientError, NoCredentialsError

def list_glue_registries(region_name='us-east-1', max_results=None):
    """
    List all AWS Glue registries in the account
    
    Args:
        region_name: AWS region name
        max_results: Maximum number of registries to return
    
    Returns:
        Dictionary containing registry information
    """
    try:
        session = boto3.session.Session()
        glue_client = session.client('glue', region_name=region_name)
        
        params = {}
        if max_results:
            params['MaxResults'] = max_results
            
        response = glue_client.list_registries(**params)
        
        print(f"Found {len(response['Registries'])} registries")
        return response
        
    except NoCredentialsError:
        print("Error: AWS credentials not found")
        return None
    except ClientError as e:
        error_code = e.response['Error']['Code']
        print(f"AWS API Error [{error_code}]: {e.response['Error']['Message']}")
        return None
    except Exception as e:
        print(f"Unexpected error: {str(e)}")
        return None

# Usage example
registries = list_glue_registries()
if registries:
    for registry in registries['Registries']:
        print(f"Registry: {registry['RegistryName']} - Status: {registry['Status']}")

Conclusion

The list_registries() method in boto3 provides an easy way to retrieve all AWS Glue registries in your account. Always include proper error handling and consider pagination for accounts with many registries.

Updated on: 2026-03-25T18:43:20+05:30

211 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements