  def RevokeOldSessionsForRole(self, role_name: str) -> None:
    """Revoke old session tokens for a role.

    This is achieved by adding an inline policy to the role, Deny *:* on the
    condition of TokenIssueTime.

    Args:
      role_name (str): The role name to act on.

    Raises:
      ResourceNotFoundError: If an inline policy could not be added to an IAM
        role.
    """
    now = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.000Z")
    policy = json.loads(ReadPolicyDoc(IAM_DENY_ALL_AFTER_TOKEN_ISSUE_DATE))
    policy['Statement'][0]['Condition']['DateLessThan']['aws:TokenIssueTime']\
      = now
    policy = json.dumps(policy)

    try:
      self.client.put_role_policy(
        RoleName=role_name,
        PolicyName='RevokeOldSessions',
        PolicyDocument=policy
      )
    except self.client.exceptions.ClientError as exception:
      raise errors.ResourceNotFoundError(
        'Could not add inline policy to IAM role {0:s}: {1!s}'.format(
          role_name, exception), __name__) from exception
Revoke old session tokens for a role.

This is achieved by adding an inline policy to the role, Deny *:* on the
condition of TokenIssueTime.

Args:
role_name (str): The role name to act on.

Raises:
ResourceNotFoundError: If an inline policy could not be added to an IAM
role.
libcloudforensics/providers/aws/internal/iam.py