使用AWS LAMBDA删除旧的手动Cluster Snaphots RDS [英] Delet old Manual Cluster Snaphots RDS using AWS LAMBDA
本文介绍了使用AWS LAMBDA删除旧的手动Cluster Snaphots RDS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的AWS Lambda的python代码下面,我想通过使用它删除OLD MANUAL RDS SNAPSHOTS,但它仍无法正常工作,我需要帮助来调试和更正此Lambda脚本.非常感谢.
below the python code of my AWS Lambda, i want to delete OLD MANUAL RDS SNAPSHOTS by using it, and it still not working with errors, i need help please for debugging and correcting this lambda script. thanks a lot of.
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()
推荐答案
您的代码看起来不错,但是您应该删除 delete_db_cluster_snapshot()
子功能:
Your code looks fine, but you should remove the delete_db_cluster_snapshot()
sub-function:
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"])
这篇关于使用AWS LAMBDA删除旧的手动Cluster Snaphots RDS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文