Service Mappings

Provides a way to map resources back to the regions they reside in as well as expose other metadata.

In some cases we need to perform additional API calls to discover the region in which a resource resides. The most well-known example of this is s3 buckets which require an additional API call to get their region. When a resource is passed in that doesn’t have a Global Service Mapping, the Session’s region is used.

Additionally this is used to expose information about whether custom resources should be stored as secondary attributes or resources.

class CloudWandererResourceMapping(service_mapping, name, mapping, resource_definition, boto3_client)

CloudWanderer specific information about a boto3 resource.


Return the resource passed in.


resource (boto3.resources.model.ResourceModel) – The ResourceModel to get the region for

Return type


property has_secondary_attributes

Return True if this resource has secondary attributes.

property resource_type

Return the resource type (e.g. Resource, SecondaryAttribute).


AttributeError – Occurs if this resource’s mapping does not have a type.

property secondary_attributes

Return a list of secondary attributes for this resource.

exception GlobalServiceResourceMappingNotFound

Global Service Resource Mapping not Found.

class ServiceMapping(service_name, service_mapping, boto3_session=None)

Expose additional metadata about services and resources that isn’t supported in boto3’s model.


Get the resource mapping for resource_type.


resource_type (str) – The resource type in PascalCase (e.g. 'Vpc').


GlobalServiceResourceMappingNotFound – Occurs if theres no global resource mapping for this service.

Return type


get_resource_region(resource, default_region)

Get the region of a boto3.resources.model.ResourceModel object.

Return type


property global_service_region

Return the primary region for this global service (if it not one, return None).

property has_regional_resources

Return True if this service has resources in regions other than the primary service region.

Also returns True if there is no service_mapping (i.e. this is not a known service).


AttributeError – Occurs if the service does not have a regionalResources key in its definition.

property is_global_service

Return whether this mapping is for a global service.


AttributeError – Occurs if the service does not have globalService key in its definition.

property resources

Return a list of resources we have mappings for.

class ServiceMappingCollection(boto3_session=None)

Load and retrieve service mappings.


boto3_session (boto3.session.Session) – The boto3.session.Session object to use for any queries.


Return the mapping for service_name.


service_name (str) – The name of the service (e.g. 'ec2')

Return type



Return our custom resource definitions.

Return type