def parse_arguments()

in Onboarding/AWS/GrantAccessToEksClusters.py [0:0]


def parse_arguments() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description=f"Granting access to MDC to query EKS clusters."
                                                 f"\nThe script adds MDC role {DEFAULT_ROLE_ARN_TO_MAP.format('<account id>')} to the aws-auth of specified EKS clusters.")
    regions_group = parser.add_mutually_exclusive_group(required=True)
    regions_group.add_argument("--regions", nargs='+', help="List of AWS regions, separated by space", type=str)
    regions_group.add_argument("--all-regions", help="Run for all available AWS regions (if there is a region with no EKS clusters, the script would skip it)", action="store_true")
    regions_group.add_argument("--regions-file", help="A path to a txt file contains a list of regions separated by new lines", type=str)

    roles_group = parser.add_mutually_exclusive_group(required=True)
    roles_group.add_argument("--roles", nargs='+', help="List of IAM roles names (or ARNs), separated by space", type=str)
    roles_group.add_argument("--roles-file", help="A path to a txt file contains a list of IAM roles names (or ARNs) separated by new lines", type=str)

    clusters_group = parser.add_mutually_exclusive_group(required=True)
    clusters_group.add_argument("--clusters", nargs='+', help="List of EKS clusters name (that deployed in the provided regions), separated by space", type=str)
    clusters_group.add_argument("--all-clusters", help="Run for all EKS clusters in the provided regions", action="store_true")
    clusters_group.add_argument("--clusters-file", help="A path to a txt file contains a list of EKS clusters name separated by new lines", type=str)

    parser.add_argument("--profile", help=f"AWS profile name (default: {DEFAULT_PROFILE_NAME})", type=str, default=DEFAULT_PROFILE_NAME, required=False)
    parser.add_argument("--output-file", help=f"A path to a txt file which will contain the script summary (In addition to showing the summary in the console)\n"
                                              f"Please note: if the file does not exist, hte script would create it in the specified location", default="", type=str, required=False)

    parser.add_argument("--role-arn", help=f"The role arn to map to system:masters group in aws-auth ConfigMap (default: {DEFAULT_ROLE_ARN_TO_MAP.format('account')})", type=str,
                        default=DEFAULT_ROLE_ARN_TO_MAP, required=False)
    args = parser.parse_args()
    return args