Cloudwanderer Boto3 Interface¶
Code which abstracts away the majority of boto3 interrogation.
Provides simpler methods for CloudWanderer
to call.
-
class
CloudWandererBoto3Interface
(boto3_session=None)¶ Simplifies lookup of boto3 services and resources.
-
__init__
(boto3_session=None)¶ Simplifies lookup of boto3 services and resources.
- Parameters
boto3_session (boto3.session.Session) – A boto3 session, if not provided the default will be used.
- Return type
None
-
property
account_id
¶ Return the AWS Account ID our Boto3 session is authenticated against.
-
property
enabled_regions
¶ Return a list of enabled regions in this account.
-
get_all_resource_services
(**kwargs)¶ Return all boto3 service Resource objects.
- Parameters
**kwargs – Additional keyword argumentss will be passed down to the Boto3 client.
- Return type
Iterator[boto3.resources.base.ServiceResource]
-
get_child_resource_definitions
(service_name, boto3_resource_model, resource_type)¶ Return all secondary attributes models for this resource.
Subresources and collections on custom service resources may be secondary attribute definitions if specified in metadata.
- Parameters
service_name (str) – The name of the service this model resides in (e.g.
'ec2'
)boto3_resource_model (boto3.resources.model.ResourceModel) – The
boto3.resources.model.ResourceModel
to get secondary attributes models fromresource_type (str) – The resource types to return (either ‘secondaryAttribute’ or ‘resource’)
- Return type
-
get_child_resources
(boto3_resource, resource_type)¶ Return all child resources of resource_type for this resource.
- Parameters
boto3_resource (boto3.resources.base.ServiceResource) – The
boto3.resources.base.ServiceResource
to get secondary attributes fromresource_type (str) – The resource types to return (either ‘secondaryAttribute’ or ‘resource’)
- Return type
-
get_resource_collection_by_resource_type
(boto3_service, resource_type)¶ Yield the resource collection that matches the resource_type (e.g. instance).
This is as opposed to the collection name (e.g. instances)
- Parameters
boto3_service (boto3.resources.base.ServiceResource) – The service resource from which to return collections
resource_type (str) – The resource type for which to return collections
- Return type
Iterator[boto3.resources.model.Collection]
-
get_resource_collections
(boto3_service)¶ Return all resource types in this service.
- Parameters
boto3_service (boto3.resources.base.ServiceResource) – The service resource from which to return collections
- Return type
-
get_resource_from_collection
(boto3_service, boto3_resource_collection)¶ Return all resources of this resource type (collection) from this service.
- Parameters
boto3_service (boto3.resources.base.ServiceResource) – The service resource from which to return resources.
boto3_resource_collection (boto3.resources.model.Collection) – The resource collection to get.
- Raises
botocore.exceptions.ClientError – A Boto3 client error.
- Return type
Iterator[boto3.resources.model.ResourceModel]
-
get_resource_service_by_name
(service_name, **kwargs)¶ Get the resource definition matching this service name.
- Parameters
service_name (str) – The name of the service (e.g.
'ec2'
) to get.**kwargs – Additional keyword argumentss will be passed down to the Boto3 client.
- Return type
-
get_resources_of_type
(service_name, resource_type, region_name=None, **kwargs)¶ Return all resources of resource_type from all definition sources.
- Parameters
service_name (str) – The name of the service to get resource for (e.g.
'ec2'
)resource_type (str) – The type of resource to get resources of (e.g.
'instance'
)region_name (str) – The region to get resources of (e.g.
'eu-west-1'
)**kwargs – Additional keyword argumentss will be passed down to the Boto3 client.
- Return type
Iterator[boto3.resources.model.ResourceModel]
-
get_secondary_attributes
(boto3_resource)¶ Return all secondary attributes resources for this resource.
Subresources and collections on custom service resources may be secondary attribute definitions if specified in metadata.
- Parameters
boto3_resource (boto3.resources.base.ServiceResource) – The
boto3.resources.base.ServiceResource
to get secondary attributes from- Return type
-
get_service_resource_collections
(service_name)¶ Return all the resource collections for a given service_name.
This is crucial to return collections for both native boto3 resources and custom cloudwanderer resources.
- Parameters
service_name (str) – The name of the service to get resource types for (e.g.
'ec2'
)- Return type
Iterator[boto3.resources.model.Collection]
-
get_service_resource_types
(service_name)¶ Return all possible resource names for a given service.
Returns resources for both native boto3 resources and custom cloudwanderer resources.
- Parameters
service_name (str) – The name of the service to get resource types for (e.g.
'ec2'
)- Return type
Iterator[str]
-
get_service_resource_types_from_collections
(collections)¶ Return all possible resource names for a given service.
Returns resources for both native boto3 resources and custom cloudwanderer resources.
- Parameters
collections (List[Collection]) – The list of collections from which to get resource names.
- Return type
Iterator[str]
-
get_shape
(boto3_resource)¶ Return the Botocore shape of a boto3 Resource.
- Parameters
boto3_resource (boto3.resources.base.ServiceResource) – The resource to get the shape of.
- Return type
botocore.model.Shape
-
get_subresources
(boto3_resource)¶ Return all subresources for this resource.
Subresources and collections on custom service resources may be subresources we want to collect if they are specified in our custom resource definitions.
- Parameters
boto3_resource (boto3.resources.base.ServiceResource) – The
boto3.resources.base.ServiceResource
to get secondary attributes from- Return type
-
property
region_name
¶ Return the default AWS region.
-
resource_regions_returned_from_api_region
(service_name, region_name)¶ Return a list of regions which will be discovered for this resource type in this region.
Usually this will just return the region which is passed in, but some resources are only queryable from a single region despite having resources from multiple regions (e.g. s3 buckets)
- Parameters
service_name (str) – The name of the service to check (e.g.
'ec2'
)region_name (str) – The name of the region to check (e.g.
'eu-west-1'
)
- Return type
Iterator[str]
-