【发布时间】:2019-08-20 14:11:18
【问题描述】:
如何按当天过滤 AWS EC2 快照?
我正在使用下面的 python 代码按标签:Disaster_Recovery 过滤快照,值为:Full,我还需要在当天过滤它。
import boto3
region_source = 'us-east-1'
client_source = boto3.client('ec2', region_name=region_source)
# Getting all snapshots as per specified filter
def get_snapshots():
response = client_source.describe_snapshots(
Filters=[{'Name': 'tag:Disaster_Recovery', 'Values': ['Full']}]
)
return response["Snapshots"]
print(*get_snapshots(), sep="\n")
【问题讨论】:
-
使用开始时间过滤器。对于值,请使用 python datetime 包中的某些内容。 boto3.amazonaws.com/v1/documentation/api/latest/reference/…
标签: python amazon-web-services aws-lambda boto3 snapshot