manheim_c7n_tools.s3_archiver module

class manheim_c7n_tools.s3_archiver.S3Archiver(region_name, bucket_name, conf_file, dryrun=False)[source]

Bases: object

_get_policy_names()[source]

Read the custodian config file; return a list of policy names.

Returns:list of policy names
Return type:list
_get_s3_policy_prefixes()[source]

Find all of the per-policy prefixes (a.k.a. “directories”) in the S3 bucket. Return a list of them

Returns:list of per-policy prefixes in S3 bucket
Return type:list
_move_prefix(policy_name)[source]

Given a policy name key prefix in S3, move everything under it to the archived-logs/ prefix.

Parameters:policy_name (str) – name of the policy prefix in S3
_s3_move_file(obj_summary, dest_key)[source]

S3 doesn’t have any built-in logic for “moving” or “renaming” an object. The way awscli and all of the SDK examples do this is by copying the source to the destination, then deleting the source. To make this a bit more unweildy, it’s far easier to copy with the boto3 client than with the fancy Resource-oriented API.

Parameters:
  • obj_summary (boto3.S3.ObjectSummary) – the S3 ObjectSummary instance to move
  • dest_key (str) – S3 key to move to
run()[source]
manheim_c7n_tools.s3_archiver.main()[source]
manheim_c7n_tools.s3_archiver.parse_args(argv)[source]