def test_from_arn(self):
        domain_key = DomainKey.from_arn(
            "arn:aws:es:us-east-1:012345678901:domain/my-es-domain")

        assert domain_key.domain_name == "my-es-domain"
        assert domain_key.region == "us-east-1"
        assert domain_key.account == "012345678901"
Beispiel #2
0
def _ensure_domain_exists(arn: ARN) -> None:
    """
    Checks if the domain for the given ARN exists. Otherwise, a ValidationException is raised.

    :param arn: ARN string to lookup the domain for
    :return: None if the domain exists, otherwise raises an exception
    :raises: ValidationException if the domain for the given ARN cannot be found
    """
    domain_key = DomainKey.from_arn(arn)
    region = OpenSearchServiceBackend.get(domain_key.region)
    domain_status = region.opensearch_domains.get(domain_key.domain_name)
    if domain_status is None:
        raise ValidationException("Invalid ARN. Domain not found.")
 def test_from_arn_wrong_service(self):
     with pytest.raises(ValueError):
         DomainKey.from_arn("arn:aws:sqs:us-east-1:012345678901:my-queue")