在我的AWS Lambda的python代码下面,我想通过使用它删除旧的手动RDS快照,但是它仍然不能处理错误,我需要帮助--请帮助调试和更正这个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()发布于 2020-10-14 22:15:14
您的代码看起来很好,但是您应该删除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"])https://stackoverflow.com/questions/64357939
复制相似问题