【发布时间】:2016-10-04 23:55:55
【问题描述】:
我对这个 method get_waiter(waiter_name) 很感兴趣。服务员的例子在这个page。我到处寻找,但找不到这个特定服务的完整服务员列表(也适用于 Python 和 PHP)。
基本上,我想要做的是在继续下一个任务之前获取应用或环境的状态并验证它是否良好。
如果来自 AWS 响应的状态与我期望的状态匹配,我目前的方法是使用 while 循环和 break。我认为这不是处理这个问题的最好方法。如果我错了,请纠正我。
这是我用 Python 编写的代码中的 sn-p:
# Check the application status
while True:
try:
response = eb.describe_application_versions(
ApplicationName=app_name,
VersionLabels=[
new_app_version
]
)
status = 'PROCESSED'
app_status = response['ApplicationVersions'][0]['Status']
if status == app_status:
print('Application Status:\t', app_status)
break
except:
raise
# Deploy the app to Elastic Beanstalk
try:
response = eb.update_environment(
ApplicationName=app_name,
EnvironmentId=env_id,
VersionLabel=new_app_version
)
except:
raise
# Check environment health
while True:
try:
response = eb.describe_environment_health(
EnvironmentId=env_id,
AttributeNames=[
'Status'
]
)
status = 'Ready'
env_status = response['Status']
if status == env_status:
print('Environment Status:\t', env_status)
break
except:
raise
【问题讨论】:
标签: python amazon-web-services sdk boto