【发布时间】:2021-01-29 03:11:37
【问题描述】:
在我的 AWS Lambda 的 python 代码下面,我想通过使用它来删除 OLD MANUAL RDS SNAPSHOTS,但它仍然无法解决错误,我需要帮助来调试和更正这个 lambda 脚本。非常感谢。
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):
delete_db_cluster_snapshot():
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"])
delete_db_cluster_snapshot()
【问题讨论】:
-
错误是什么?
标签: python amazon-web-services aws-lambda amazon-rds aws-serverless