def mkbucket(bucket): name = bucket['Name'] region_name = s3.get_bucket_location(Bucket=name)[ "LocationConstraint"] return newTarget("s3_bucket", region_name, [name])
def mkstack(region, stack_summary): return newTarget("cloudformation_stack", region, [stack_summary['StackName']], { "StackStatus": stack_summary['StackStatus'], "ExtraStr": stack_summary['StackStatus'], })
def chase(bucket): bucketNames = bucket.get("resource_names", []) if len(bucketNames) > 0: bucketName = bucketNames[0] region = bucket["region"] objects = list_objects(bucketName, region) empty_bucket = newTarget("s3_empty_bucket", bucket["region_name"], [bucketName]) targets = objects + [empty_bucket] return targets else: return []
def list_objects(bucketName, region): kwargs = {'Bucket': bucketName} # TODO: Support large (>1000) buckets list_object_versions = s3.list_object_versions(**kwargs) versions = list_object_versions.get("Versions", []) objects = list(map(mkversion, versions)) result = [] if objects: result = [ newTarget("s3_objects", region, objects, {"bucket-name": bucketName}) ] return result
def list_objects(bucketName, region): kwargs = {'Bucket': bucketName} # TODO: Support large (>1000) buckets list_object_versions = s3.list_object_versions(**kwargs) versions = list_object_versions.get("Versions", []) objects = list(map(mkversion, versions)) result = [] if objects: result = [newTarget("s3_objects", region, objects, { "bucket-name": bucketName })] return result
def mkbucket(bucket): name = bucket['Name'] region_name = s3.get_bucket_location(Bucket=name)["LocationConstraint"] return newTarget("s3_bucket", region_name, [name])
def chase(target): return [newTarget("ec2_instances", region=target["region"])]
def mkstack(region, stack_summary): return newTarget( "cloudformation_stack", region, [stack_summary['StackName']], { "StackStatus": stack_summary['StackStatus'], "ExtraStr": stack_summary['StackStatus'], })