import json import os import sys from pulumi.schema import StackExport from utils import read_json_file if __name__ == '__main__': export_file = sys.argv[1] exported = read_json_file(export_file) export_data = StackExport(exported) ekses = [ "eu-central-1-f01", "ap-southeast-1-f01", "ap-northeast-1-f01", "us-west-2-f01", "us-west-2-f02", "us-east-1-f01", "us-east-1-f02", ] splited = export_data.split_resource_by_urns(ekses) # remove by blacklist black_list = [ "urn:pulumi:prod::tidb-gateway::pulumi:providers:aws::aws-provider-eu-central-1", "urn:pulumi:prod::tidb-gateway::pulumi:providers:aws::aws-provider-ap-southeast-1", "urn:pulumi:prod::tidb-gateway::pulumi:providers:aws::aws-provider-ap-northeast-1", "urn:pulumi:prod::tidb-gateway::pulumi:providers:aws::aws-provider-us-west-2", "urn:pulumi:prod::tidb-gateway::pulumi:providers:aws::aws-provider-us-east-1", ] for i in range(len(ekses)): tmp = black_list.copy() tmp.remove(black_list[i]) splited[i].filterout_by_urns(tmp) for i in range(len(ekses)): print("============ start counting resources of {} ============".format(ekses[i])) splited[i].echo_resource_cnt() print("============ end counting resources of {} ============".format(ekses[i])) path = "./output/splitted.{}.json".format(ekses[i]) os.makedirs(os.path.dirname(path), exist_ok=True) f = open(path, "w") f.write(json.dumps(splited[i].to_json(), indent=4))