1 回答
TA贡献1906条经验 获得超10个赞
您的代码看起来不错,但您应该删除子函数:delete_db_cluster_snapshot()
import boto3
from os import getenv
import datetime
from datetime import date
client = boto3.client('rds')
ClientName = getenv('CLIENT_NAME')
today = date.today()
def lambda_handler(event, context):
snapshots_marker = ""
while snapshots_marker != None:
snapshots = client.describe_db_cluster_snapshots(Marker=snapshots_marker)
if 'Marker' in snapshots:
snapshots_marker = snapshots['Marker']
else:
snapshots_marker = None
for snapshot in snapshots['DBClusterSnapshots']:
if snapshot["SnapshotType"] == "manual" and ClientName in snapshot["DBClusterIdentifier"] and snapshot ["SnapshotCreateTime"].date() < today:
client.delete_db_cluster_snapshot(DBClusterSnapshotIdentifier=snapshot["DBClusterSnapshotIdentifier"])
- 1 回答
- 0 关注
- 109 浏览
添加回答
举报