def is_valid_mrk_identifier()

in src/aws_encryption_sdk/internal/arn.py [0:0]


def is_valid_mrk_identifier(id_str):
    """Determines whether a string can be interpreted as
    a valid MRK identifier; either an MRK arn or a raw resource ID for an MRK.

    :param str id_str: The string to parse.
    :returns: a bool representing whether this key identifier indicates an MRK
    :rtype: bool
    :raises MalformedArnError: if the string starts with "arn:" but fails to parse as an ARN
    """
    # //= compliance/framework/aws-kms/aws-kms-key-arn.txt#2.9
    # //# This function MUST take a single AWS KMS identifier

    if id_str.startswith("arn:"):
        # //= compliance/framework/aws-kms/aws-kms-key-arn.txt#2.9
        # //# If the input starts with "arn:", this MUST return the output of
        # //# identifying an an AWS KMS multi-Region ARN (aws-kms-key-
        # //# arn.md#identifying-an-an-aws-kms-multi-region-arn) called with this
        # //# input.
        return is_valid_mrk_arn_str(id_str)
    elif id_str.startswith("alias/"):
        # //= compliance/framework/aws-kms/aws-kms-key-arn.txt#2.9
        # //# If the input starts with "alias/", this an AWS KMS alias and not a
        # //# multi-Region key id and MUST return false.
        return False
    elif id_str.startswith("mrk-"):
        # //= compliance/framework/aws-kms/aws-kms-key-arn.txt#2.9
        # //# If the input starts with "mrk-", this is a multi-Region key id and
        # //# MUST return true.
        return True
    else:
        # //= compliance/framework/aws-kms/aws-kms-key-arn.txt#2.9
        # //# If
        # //# the input does not start with any of the above, this is a multi-
        # //# Region key id and MUST return false.
        return False