You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario - Unit testing an aws lambda function using moto library
I am using copy_db_cluster_snapshot() method from moto rds for cross-region copy of snapshot using source_snapshot_arn in the parameter but the result of the same is not as expected in real boto3 world.
How to reproduce the issue -
We can use below code snippet to execute in snapshot copy in moto rds world for unit test purpose
try:
response = destination_rds_client.copy_db_cluster_snapshot(
SourceDBClusterSnapshotIdentifier=source_snapshot_arn,
TargetDBClusterSnapshotIdentifier=destination_snapshot_identifier,
KmsKeyId=KmsKeyId
)
print(f"Snapshot Copy initiated successfully: {response}")
return {
'statusCode': 200,
'body': json.dumps('Snapshot copy initiated successfully!')
}
except Exception as e:
print(f"Error copying snapshot:{e}")
return {
'statusCode': 500,
'body': json.dumps(f"Error Copying Snapshot: {str(e)}")
}
In parameters to method of copy_db_cluster_snapshot() i am passing source_snapshot_arn instead of source_snapshot_identifier which is expected for cross region copy but it is raising below mentioned error
Actual result(Error) - FileBasedAssertJsonOutputEquals test_happy_path Actual {
"test_exception": null,
"test_results": {
"body": "\"Error Copying Snapshot: An error occurred (DBClusterSnapshotNotFoundFault) when calling the CopyDBClusterSnapshot operation: DBClusterSnapshot arn:aws:rds:us-east-1:123456789012:cluster-snapshot:mytestdbclustersnapshot not found.\"",
"statusCode": 500
}
Moto does not currently support copying RDS snapshots cross-region or cross-account. I've marked this as an enhancement. You are welcome to submit a PR with this functionality. Otherwise, it will be picked up when/if time allows.
bpandola
changed the title
source_snapshot_arn is giving not found error in copy_db_cluster_snapshot() in moto rds
RDS: Support Cross-Region Snapshot Copy
Dec 12, 2024
@bpandola I have started to make the code changes on my local to make this feature available. Can you pls guide me through the steps to complete this contribution and also how to test my added changes ?
@Dipesh9798 RDS tests are here. You'll want to write a test that creates an RDS instance, takes a snapshot, and then copies it to another region. Your test should verify that the snapshot exists in the target region after the copy.
Scenario - Unit testing an aws lambda function using moto library
I am using copy_db_cluster_snapshot() method from moto rds for cross-region copy of snapshot using source_snapshot_arn in the parameter but the result of the same is not as expected in real boto3 world.
How to reproduce the issue -
We can use below code snippet to execute in snapshot copy in moto rds world for unit test purpose
try:
response = destination_rds_client.copy_db_cluster_snapshot(
SourceDBClusterSnapshotIdentifier=source_snapshot_arn,
TargetDBClusterSnapshotIdentifier=destination_snapshot_identifier,
KmsKeyId=KmsKeyId
)
print(f"Snapshot Copy initiated successfully: {response}")
return {
'statusCode': 200,
'body': json.dumps('Snapshot copy initiated successfully!')
}
except Exception as e:
print(f"Error copying snapshot:{e}")
return {
'statusCode': 500,
'body': json.dumps(f"Error Copying Snapshot: {str(e)}")
}
In parameters to method of copy_db_cluster_snapshot() i am passing source_snapshot_arn instead of source_snapshot_identifier which is expected for cross region copy but it is raising below mentioned error
Actual result(Error) - FileBasedAssertJsonOutputEquals test_happy_path Actual {
}
Expected result - test_happy_path {
}
Version used in python env.
Moto == 4.0.11
boto3== 1.24.96
botocore== 1.27.96
How can we resolve the same or take this forward to get it fixed in moto rds implementation?
The text was updated successfully, but these errors were encountered: