2016-10-04 45 views
0

我對此 get_waiter(waiter_name)感興趣。服務員的例子在這page。我到處尋找,但我找不到這個特定服務的服務員的完整列表(對於Python和PHP)。AWS SDK | Elastic Beanstalk的服務員名單

基本上,我想要發生的是獲得應用程序或環境的狀態,並驗證它是好的,然後再轉到下一個任務。

我的當前方法是使用while循環,如果AWS響應的狀態與我期望的狀態匹配,則使用break。我認爲這不是解決這個問題的最好方法。如果我錯了,請糾正我。

下面是從我的代碼用Python編寫的代碼片段:

# 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 

回答