如何在python中使用而True ?在这里,我试图编写一个python boto3脚本来停止所有处于可用状态的 RDS 实例。在停止之前,我需要将 MultiAZ 部署的实例更改为无。我想等待实例按顺序修改以停止实例。如何通过等到条件变为真实来完成同样的事情?
import boto3
client = boto3.client('rds')
dbmultiAZ=[]
def lambda_handler(event,context):
response=client.describe_db_instances()
for i in response['DBInstances']:
if i['DBInstanceStatus'] == 'available':
dbmultiAZ.append(i['DBInstanceIdentifier'])
for j in dbmultiAZ:
if i['MultiAZ']==True:
response1 = client.modify_db_instance(
DBInstanceIdentifier=i['DBInstanceIdentifier'],
ApplyImmediately=True,
MultiAZ=False
)
else:
dbmultiAZ.append(i['DBInstanceIdentifier'])
for z in dbmultiAZ:
waiter = client.get_waiter('db_instance_available')
waiter.wait(
DBInstanceIdentifier=z )
response2 = client.stop_db_instance(
DBInstanceIdentifier=z
)