# Path: repokid/exceptions.py
# class IAMError(Exception):
#     pass


import datetime
import json
import logging
import re
import botocore
from typing import Any
from typing import Dict
from cloudaux.aws.iam import delete_role_policy
from cloudaux.aws.iam import put_role_policy
from cloudaux.aws.sts import boto3_cached_conn
from mypy_boto3_iam.client import IAMClient
from repokid.exceptions import IAMError
        role (Role object)
        account_number (string)
        conn (dict)

    Returns:
        error (string) or None
    """
    LOGGER.info(
        "Replacing Policies With: \n{} (role: {} account: {})".format(
            json.dumps(repoed_policies, indent=2, sort_keys=True),
            role_name,
            account_number,
        )
    )

    for policy_name, policy in repoed_policies.items():
        try:
            put_role_policy(
                RoleName=role_name,
                PolicyName=policy_name,
                PolicyDocument=json.dumps(policy, indent=2, sort_keys=True),
                **conn,
            )

        except botocore.exceptions.ClientError as e:
            error = "Exception calling PutRolePolicy on {role}/{policy} in account {account}".format(
                role=role_name,
                policy=policy_name,
                account=account_number,
            )

# Path: repokid/exceptions.py
# class IAMError(Exception):
#     pass


# Path: repokid/utils/iam.py
import datetime
import json
import logging
import re
import botocore
from typing import Any
from typing import Dict
from cloudaux.aws.iam import delete_role_policy
from cloudaux.aws.iam import put_role_policy
from cloudaux.aws.sts import boto3_cached_conn
from mypy_boto3_iam.client import IAMClient
from repokid.exceptions import IAMError

        role (Role object)
        account_number (string)
        conn (dict)

    Returns:
        error (string) or None
    """
    LOGGER.info(
        "Replacing Policies With: \n{} (role: {} account: {})".format(
            json.dumps(repoed_policies, indent=2, sort_keys=True),
            role_name,
            account_number,
        )
    )

    for policy_name, policy in repoed_policies.items():
        try:
            put_role_policy(
                RoleName=role_name,
                PolicyName=policy_name,
                PolicyDocument=json.dumps(policy, indent=2, sort_keys=True),
                **conn,
            )

        except botocore.exceptions.ClientError as e:
            error = "Exception calling PutRolePolicy on {role}/{policy} in account {account}".format(
                role=role_name,
                policy=policy_name,
                account=account_number,
            )

            raise IAMError(error) from e