Add check for UnknownSnapshotCopyRegionFault
error
This commit is contained in:
parent
b4d7d183ab
commit
cf7869d0e2
@ -150,3 +150,10 @@ class InvalidParameterCombinationError(RedshiftClientError):
|
|||||||
super(InvalidParameterCombinationError, self).__init__(
|
super(InvalidParameterCombinationError, self).__init__(
|
||||||
"InvalidParameterCombination", message
|
"InvalidParameterCombination", message
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownSnapshotCopyRegionFaultError(RedshiftClientError):
|
||||||
|
def __init__(self, message):
|
||||||
|
super(UnknownSnapshotCopyRegionFaultError, self).__init__(
|
||||||
|
"UnknownSnapshotCopyRegionFault", message
|
||||||
|
)
|
||||||
|
@ -26,6 +26,7 @@ from .exceptions import (
|
|||||||
SnapshotCopyDisabledFaultError,
|
SnapshotCopyDisabledFaultError,
|
||||||
SnapshotCopyGrantAlreadyExistsFaultError,
|
SnapshotCopyGrantAlreadyExistsFaultError,
|
||||||
SnapshotCopyGrantNotFoundFaultError,
|
SnapshotCopyGrantNotFoundFaultError,
|
||||||
|
UnknownSnapshotCopyRegionFaultError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -577,6 +578,10 @@ class RedshiftBackend(BaseBackend):
|
|||||||
raise InvalidParameterValueError(
|
raise InvalidParameterValueError(
|
||||||
"SnapshotCopyGrantName is required for Snapshot Copy on KMS encrypted clusters."
|
"SnapshotCopyGrantName is required for Snapshot Copy on KMS encrypted clusters."
|
||||||
)
|
)
|
||||||
|
if kwargs["destination_region"] == self.region:
|
||||||
|
raise UnknownSnapshotCopyRegionFaultError(
|
||||||
|
"Invalid region {}".format(self.region)
|
||||||
|
)
|
||||||
status = {
|
status = {
|
||||||
"DestinationRegion": kwargs["destination_region"],
|
"DestinationRegion": kwargs["destination_region"],
|
||||||
"RetentionPeriod": kwargs["retention_period"],
|
"RetentionPeriod": kwargs["retention_period"],
|
||||||
|
@ -1268,6 +1268,15 @@ def test_enable_snapshot_copy():
|
|||||||
ex.value.response["Error"]["Message"].should.contain(
|
ex.value.response["Error"]["Message"].should.contain(
|
||||||
"SnapshotCopyGrantName is required for Snapshot Copy on KMS encrypted clusters."
|
"SnapshotCopyGrantName is required for Snapshot Copy on KMS encrypted clusters."
|
||||||
)
|
)
|
||||||
|
with pytest.raises(ClientError) as ex:
|
||||||
|
client.enable_snapshot_copy(
|
||||||
|
ClusterIdentifier="test",
|
||||||
|
DestinationRegion="us-east-1",
|
||||||
|
RetentionPeriod=3,
|
||||||
|
SnapshotCopyGrantName="invalid-us-east-1-to-us-east-1",
|
||||||
|
)
|
||||||
|
ex.value.response["Error"]["Code"].should.equal("UnknownSnapshotCopyRegionFault")
|
||||||
|
ex.value.response["Error"]["Message"].should.contain("Invalid region us-east-1")
|
||||||
client.enable_snapshot_copy(
|
client.enable_snapshot_copy(
|
||||||
ClusterIdentifier="test",
|
ClusterIdentifier="test",
|
||||||
DestinationRegion="us-west-2",
|
DestinationRegion="us-west-2",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user