如何指向我最近的 RDS 数据库快照的标识符?
How do I point to the the identifier of my most recent RDS DB snapshot?
我正在尝试在 Lambda 函数中使用 Boto3 restore_db_instance_from_db_snapshot() 方法。所需参数之一是我要从中恢复的快照标识符。我想避免每次都手动输入标识符,而是指向最近的快照标识符。我该怎么做?
我正在使用 Python 3.7 顺便说一句。
您可以调用 describe_db_snapshots()
来检索快照列表。
您可以提供 DBInstanceIdentifier
来请求与特定数据库相关的快照列表。
响应将是 Python list of DBSnapshots
。您可以使用 Python 按 SnapshotCreateTime
对列表进行排序,然后检索 DBSnapshotIdentifier
以获得最新的快照。
我正在尝试在 Lambda 函数中使用 Boto3 restore_db_instance_from_db_snapshot() 方法。所需参数之一是我要从中恢复的快照标识符。我想避免每次都手动输入标识符,而是指向最近的快照标识符。我该怎么做?
我正在使用 Python 3.7 顺便说一句。
您可以调用 describe_db_snapshots()
来检索快照列表。
您可以提供 DBInstanceIdentifier
来请求与特定数据库相关的快照列表。
响应将是 Python list of DBSnapshots
。您可以使用 Python 按 SnapshotCreateTime
对列表进行排序,然后检索 DBSnapshotIdentifier
以获得最新的快照。