Storage Connector Reference

DynamoDB Connector

Classes for the CloudWanderer DynamoDB Storage Connector.

class DynamoDbConnector(table_name='cloud_wanderer', endpoint_url=None, boto3_session=None, client_args=None, number_of_shards=10)

CloudWanderer Storage Connector for DynamoDB.

Parameters
  • table_name (str) – The name of the table to store resources in.

  • endpoint_url (str) – Optional override endpoint url for DynamoDB.

  • boto3_session (boto3.session.Session) – Optional boto3 session to use to interact with DynamoDB. Useful if your DynamoDB table is in a different account/region to your configured defaults.

  • number_of_shards (int) – The number of shards to break records across low-cardinality indices. Prevents hot-partitions. If you don’t know what this means, ignore this setting.

  • client_args (dict) – Arguments to pass into the boto3 client. See: boto3.session.Session.client()

delete_resource(urn)

Delete the resource and all its resource attributes from DynamoDB.

Parameters

urn (cloudwanderer.aws_urn.AwsUrn) –

Return type

None

delete_resource_of_type_in_account_region(service, resource_type, account_id, region, urns_to_keep=None)

Delete resources of type in account id unless in list of URNs.

Parameters
Return type

None

init()

Create the DynamoDB Database.

Return type

None

read_all()

Return raw data from all DynamoDB table records (not just resources).

Return type

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

read_all_resources_in_account(account_id)

Return all resources in account.

Parameters

account_id (str) – AWS Account ID

Return type

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

read_resource(urn)

Return the resource with the specified cloudwanderer.aws_urn.AwsUrn).

Parameters

urn (cloudwanderer.aws_urn.AwsUrn) – The AWS URN of the resource to return

Return type

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

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

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

read_resource_of_type_in_account(service, resource_type, account_id)

Return all resources of the specified type in the specified AWS account.

Parameters
  • service (str) – Service name, e.g. 'ec2'

  • resource_type (str) – Resource type, e.g. 'instance'

  • account_id (str) – AWS Account ID

Return type

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

write_resource(urn, resource)

Write the specified resource to DynamoDB.

Parameters
Return type

None

write_resource_attribute(urn, attribute_type, resource_attribute)

Write the specified resource attribute to DynamoDb.

Parameters
Return type

None

Base Connector

Module containing abstract classes for CloudWanderer storage connectors.

class BaseStorageConnector

Abstract class for specification of the CloudWanderer storage connector interface.

abstract delete_resource(urn)

Delete this resource and all its resource attributes.

Parameters

urn (cloudwanderer.aws_urn.AwsUrn) –

Return type

None

abstract delete_resource_of_type_in_account_region(service, resource_type, account_id, region, urns_to_keep=None)

Delete resources of type in account and region unless in list of URNs.

This is used primarily to clean up old resources.

Parameters
Return type

None

abstract read_all()

Return all records from storage.

Return type

List[dict]

abstract read_all_resources_in_account(account_id)

Return all resources from this AWS account.

Parameters

account_id (str) –

Return type

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

abstract read_resource(urn)

Return a resource matching the supplied urn from storage.

Parameters

urn (cloudwanderer.aws_urn.AwsUrn) –

Return type

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

abstract read_resource_of_type(service, resource_type)

Return all resources of this type from storage.

Parameters
  • service (str) –

  • resource_type (str) –

Return type

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

abstract read_resource_of_type_in_account(service, resource_type, account_id)

Return all resources of this type from this AWS account.

Parameters
  • service (str) –

  • resource_type (str) –

  • account_id (str) –

Return type

List[cloudwanderer.cloud_wanderer.CloudWandererResource]

abstract write_resource(urn, resource)

Persist a single resource to storage.

Parameters
Return type

None