manheim_c7n_tools.dryrun_diff module

class manheim_c7n_tools.dryrun_diff.DryRunDiffer(config)[source]

Bases: object

_find_changed_policies(git_dir=None, diff_against='master')[source]
Returns:list of policy names that differ from master
Return type:list
_get_dryrun_results(pol_names)[source]

Read the resources.json files from disk for the dryrun/ directory. Return a dictionary of string policy name to nested dictionaries, of string region name to int count of resources.

Returns:dictionary of nested dictionaries, policy name to dict of region name to resource count
Return type:dict
_get_latest_res_count_for_policy(bucket, pol_name)[source]

Given the S3 Bucket and a policy name, find the newest resources.json file for that policy and return the count of resources in it.

Parameters:
  • bucket (boto3.S3.Bucket) – the bucket to look in
  • pol_name (str) – the name of the policy
Returns:

resource count from latest run of the policy

Return type:

int

_get_s3_policy_prefixes(bucket)[source]

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

Parameters:bucket (boto3.S3.Bucket) – the S3 bucket to list policies in
Returns:list of per-policy prefixes in S3 bucket
Return type:list
_get_s3_results_for_region(region_name, changed_pols)[source]

Find the results files in S3 from the last live run of the deployed policies. Read each file, count the resources, and update self._live_results accordingly.

_make_diff_markdown(dryrun)[source]

Return GitHub-flavored Markdown showing the difference between the dryrun (this branch) and the last run of each policy on master.

Parameters:dryrun (dict) – dryrun policy resource counts
Returns:markdown diff
Return type:str
run(git_dir=None, diff_against='master')[source]
manheim_c7n_tools.dryrun_diff.main()[source]
manheim_c7n_tools.dryrun_diff.parse_args(argv)[source]