在 AWS RDS 控制台上运行以下代码可以查询预留 RDS 实例的计费状态:
import boto3
client = boto3.client('rds')
response = client.describe_reserved_db_instances()
for reserved_instance in response['ReservedDBInstances']:
print(reserved_instance['DBInstanceIdentifier'], reserved_instance['State'], reserved_instance['StartTime'])
此代码将返回 RDS 实例的 DBInstanceIdentifier、状态和预留开始时间。状态可以是如下之一:active、payment-pending、retired 和 retired-pending。如果状态为 active,则意味着预留实例正在使用中。如果状态为 payment-pending,则意味着 AWS 正在验证您的支付信息。如果状态为 retired,则意味着预留实例不再存在(已过期或已被退回)。如果状态为 retired-pending,则意味着 AWS 正在准备要退回的预留实例。
下一篇:AWS预留实例的计费