def main()

in util/generate-ami-list.py [0:0]


def main():
    """Run the script."""
    args = parse_args()
    region = PARTITION_TO_MAIN_REGION.get(args.partition)

    credentials = []
    if args.credential:
        credentials = [
            tuple(credential_tuple.strip().split(","))
            for credential_tuple in args.credential
            if credential_tuple.strip()
        ]

    if args.cookbook_git_ref and args.node_git_ref:
        # This path is used by the build_and_test and retrieve_ami_list pipelines.
        # Requiring all of the AMIs in the resulting mappings (for the applicable regions)
        # to be created from the same cookbook and node repo git refs on the same date
        # ensures that the AMIs were all produced by the same run of the build pipeline.
        amis_dict = get_ami_list_by_git_refs(
            main_region=region,
            regions=get_all_aws_regions_from_ec2(region),
            cli_git_ref=args.cli_git_ref,
            cookbook_git_ref=args.cookbook_git_ref,
            node_git_ref=args.node_git_ref,
            build_date=args.build_date,
            build_number=args.build_number,
            owner=args.account_id,
            credentials=credentials,
        )
    elif not args.json_regions or not args.json_amis:
        sys.exit(
            "Must specify value for --json-regions and --json-amis "
            "when not using --cookbook-git-ref and --node-git-ref."
        )
    else:
        # This path is used by the pre_release_flow pipeline, which uses the
        # retrieve_ami_list pipeline to generate a json file with updated mappings
        # for each partition and then aggregates the mappings from those files
        # into a single json file.
        regions = get_aws_regions_from_file(args.json_regions)
        amis_dict = get_ami_list_from_file(regions, args.json_amis)

    update_json_file(json_file_path=args.json_file, amis_to_update=amis_dict)
    write_amis_txt(amis_txt_file=args.txt_file, json_file=args.json_file)