根据“CreatedTimestamp”删除sqs队列
类似于问题 使用 boto3 批量删除 sqs 队列,我现在想删除队列基于“CreatedTimestamp”。如果创建时间(以纪元时间为单位)早于特定纪元时间戳,则应将其删除。
我尝试写一些类似于之前帖子中给出的答案的内容,但我不确定是否需要再次循环来检查创建时间。
client = boto3.client('sqs')
timestamp = '1645747200'
def delete_sqs_queues (event, context):
response = client.list_queues()
for sqs_url in response['QueueUrls']:
get_att = client.get_queue_attributes(
QueueUrl=sqs_url,
AttributeNames=['CreatedTimestamp']
)
我可以直接将 CreatedTimestamp 与变量进行比较,还是需要另一个 for 循环来迭代 CreatedTimestamp?
Similar to question Bulk delete sqs queues using boto3, I now want to delete queues based on 'CreatedTimestamp'. If the created time (in epoch time) is before a specific epoch timestamp, it should be deleted.
I tried to write something similar to answer given in the earlier post but I am not sure if I need to to loop again to check the created time.
client = boto3.client('sqs')
timestamp = '1645747200'
def delete_sqs_queues (event, context):
response = client.list_queues()
for sqs_url in response['QueueUrls']:
get_att = client.get_queue_attributes(
QueueUrl=sqs_url,
AttributeNames=['CreatedTimestamp']
)
Can I directly compare the CreatedTimestamp with a variable or do I need another for loop to iterate over the CreatedTimestamps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每个队列只有一个
CreatedTimestamp
,因此您不必再次迭代:There is only one
CreatedTimestamp
for each queue, thus you don't have to iterate again: