Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDS: Support Cross-Region Snapshot Copy #8389

Open
Dipesh9798 opened this issue Dec 10, 2024 · 3 comments
Open

RDS: Support Cross-Region Snapshot Copy #8389

Dipesh9798 opened this issue Dec 10, 2024 · 3 comments

Comments

@Dipesh9798
Copy link

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

}

}

Expected result - test_happy_path {

"test_exception": null,

"test_results": {

    "body": "\"Snapshot copy initiated successfully!\"",

    "statusCode": 200

}

}

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?

@bpandola
Copy link
Collaborator

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 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
@Dipesh9798
Copy link
Author

@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 ?

@bpandola
Copy link
Collaborator

@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.

See https://github.com/getmoto/moto/blob/master/CONTRIBUTING.md for information on how to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants