#!/usr/bin/env python3
"""
Parse the HTML of https://signin.aws.amazon.com/saml to extract all assumable
roles for use in .aws/config
Usage:
aws-config-gen.py [options]
aws-config-gen.py -h | --help
aws-config-gen.py --version
Options:
-d --print-default Begin output with an empty [default] profile
-r REGION, --region=REGION Add the specified aws region to each profile
-s SUFFIX, --suffix=SUFFIX Append SUFFIX to each profile name
--version Show version info
-h --help Show this help screen
"""
import sys
from docopt import docopt
from bs4 import BeautifulSoup
from pathlib import Path
from configparser import ConfigParser
from itertools import starmap, chain
from functools import partial
def get_saml_role_arn (saml_role_tag):
saml_radio_tag = saml_role_tag.find(class_='saml-radio')
saml_role_arn = saml_radio_tag['value']
return saml_role_arn
def get_account_roles (html_file):
with open(Path(html_file).resolve()) as document:
page = BeautifulSoup(document, 'html.parser')
# The