Reputation: 25
I am trying to use the Boto3 restore_db_instance_from_db_snapshot() method in a Lambda function. One of the needed parameters is the snapshot identifier that I want to restore from. I would like to avoid manually entering the identifier each time, and instead point to the most recent snapshot identifier. How would I go about doing this?
I'm using Python 3.7 btw.
Upvotes: 0
Views: 694
Reputation: 269520
You could call describe_db_snapshots()
to retrieve a list of snapshots.
You can supply a DBInstanceIdentifier
to request a list of snapshots related to a specific database.
The response will be a Python list of DBSnapshots
. You can use Python to sort the list by SnapshotCreateTime
and then retrieve the DBSnapshotIdentifier
for the most recent snapshot.
Upvotes: 1