CloudWanderer Reference¶
Main cloudwanderer module.
-
class
CloudWanderer
(storage_connector, boto3_session=None)¶ CloudWanderer.
- Parameters
storage_connector – A CloudWanderer storage connector object.
boto3_session (boto3.session.Session) – A boto3
Session
object.
-
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.
-
read_all_resources_in_account
(account_id)¶ Return all resources in the provided AWS Account from storage.
- Parameters
account_id (str) – The account id in which to look for resources.
- Return type
-
read_resource
(urn)¶ Return a specific resource by its urn from storage.
Either use this to manually inflate the
CloudWandererResource
passsed back by other read methods or build your ownAwsUrn
to query a resource you already know exists.- Parameters
urn (cloudwanderer.aws_urn.AwsUrn) – The
AwsUrn
of the resource to retrieve.- Return type
-
read_resource_of_type
(service, resource_type)¶ Return all resources of type.
- Parameters
service (str) – Service name (e.g.
'ec2'
)resource_type (str) – Resource Type (e.g.
'instance'
)
- Return type
-
read_resource_of_type_in_account
(service, resource_type, account_id)¶ Return all resources of this type in the provided AWS Account from storage.
- Parameters
service (str) – Service name (e.g.
'ec2'
)resource_type (str) – Resource Type (e.g.
'instance'
)account_id (str) – The account id in which to look for resources.
- Return type
-
write_resource_attributes
(exclude_resources=None, client_args=None)¶ Write all AWS resource attributes in this account from all regions and all services to storage.
- Parameters
exclude_resources (list) – A list of resource names to exclude (e.g.
['instance']
)client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
None
-
write_resource_attributes_in_region
(exclude_resources=None, region_name=None, client_args=None)¶ Write all AWS resource attributes in this account in this region to storage.
These custom resource attribute definitions allow us to fetch resource attributes that are not returned by the resource’s default describe calls. Unlike
write_resources()
andwrite_resources_of_type()
this method does not clean up stale resource attributes from storage.- Parameters
exclude_resources (list) – A list of resources not to write attributes for (e.g.
['vpc']
)region_name (str) – The name of the region to get resources from (defaults to session default if not specified)
client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
None
-
write_resource_attributes_of_service_in_region
(service_name, exclude_resources=None, region_name=None, client_args=None)¶ Write all AWS resource attributes in this account in this service to storage.
These custom resource attribute definitions allow us to fetch resource attributes that are not returned by the resource’s default describe calls. Unlike
write_resources()
andwrite_resources_of_type()
this method does not clean up stale resource attributes from storage.- Parameters
service_name (str) – The name of the service to write the attributes of (e.g.
'ec2'
)exclude_resources (list) – A list of resources not to write attributes for (e.g.
['vpc']
)region_name (str) – The name of the region to get resources from (defaults to session default if not specified)
client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
None
-
write_resource_attributes_of_type_in_region
(service_name, resource_type, region_name=None, client_args=None)¶ Write all AWS resource attributes in this account of this resource type to storage.
These custom resource attribute definitions allow us to fetch resource attributes that are not returned by the resource’s default describe calls.
- Parameters
service_name (str) – The name of the service to write the attributes of (e.g.
ec2
)resource_type (str) – The type of resource to write the attributes of (e.g.
instance
)region_name (str) – The name of the region to get resources from (defaults to session default if not specified)
client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
None
-
write_resources
(exclude_resources=None, client_args=None, concurrency=1)¶ Write all AWS resources in this account from all regions and all services to storage.
- Parameters
exclude_resources (list) – A list of resource names to exclude (e.g.
['instance']
)client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
concurrency (int) – Number of query threads to invoke concurrently. If the number of threads exceeds the number of regions by at least two times multiple services to be queried concurrently in each region. WARNING: Experimental. Complete data capture depends heavily on the thread safeness of the storage connector and has not been thoroughly tested!
- Return type
None
-
write_resources_in_region
(exclude_resources=None, region_name=None, client_args=None)¶ Write all AWS resources in this account region from all services to storage.
- Parameters
exclude_resources (list) – A list of resource names to exclude (e.g.
['instance']
)region_name (str) – The name of the region to get resources from (defaults to session default if not specified)
client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
None
-
write_resources_of_service_in_region
(service_name, exclude_resources=None, region_name=None, client_args=None)¶ Write all AWS resources in this region in this service to storage.
Cleans up any resources in the StorageConnector that no longer exist.
- Parameters
service_name (str) – The name of the service to write resources for (e.g.
'ec2'
)exclude_resources (list) – A list of resource names to exclude (e.g.
['instance']
)region_name (str) – The name of the region to get resources from (defaults to session default if not specified)
client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
None
-
write_resources_of_type_in_region
(service_name, resource_type=None, region_name=None, client_args=None)¶ Write all AWS resources in this region in this service to storage.
Cleans up any resources in the StorageConnector that no longer exist.
- Parameters
service_name (str) – The name of the service to write resources for (e.g.
'ec2'
)resource_type (str) – The name of the type of the resource to write (e.g.
'instance'
)region_name (str) – The name of the region to get resources from (defaults to session default if not specified)
client_args (dict) – Arguments to pass into the boto3 client. See:
boto3.session.Session.client()
- Return type
None
-
class
CloudWandererResource
(urn, resource_data, resource_attributes=None, loader=None)¶ A simple representation of a resource that prevents any storage metadata polluting the resource dictionary.
Use
dict(my_resource_dict)
to convert this object into a dictionary that contains only the resource’s metadata.-
urn
¶ The AWS URN of the resource.
-
metadata
¶ The original storage representation of the resource as it was passed in.
- Type
dict
-
load
()¶ Inflate this resource with all data from the original storage connector it was spawned from..
- Return type
None
-
-
class
ResourceMetadata
(resource_data, resource_attributes)¶ Metadata for a
CloudWandererResource
.Contains the original dictionaries of the resource and its attributes.
-
resource_data
¶ The raw dictionary representation of the Resource.
- Type
dict
-
resource_attributes
¶ the list of raw dictionary representation of the Resource’s attributes.
- Type
list
-