from . import collect_aws_asset_snapshot import json class DatetimeEncoder(json.JSONEncoder): def default(self, obj): try: return super().default(obj) except TypeError: return str(obj) class Collector: def collect(self): self.get_aws_resources_asset_snapshot() return 'ok' def get_aws_resources_asset_snapshot(self): resources = collect_aws_asset_snapshot.crawl_all_region_aws_resources() json.dump(resources, open("aws_asset_snapshot.json", "w"), cls=DatetimeEncoder)