开发工具包 | Elastic Beanstalk 的等待者列表

AWS SDK | List of waiters for Elastic Beanstalk

我对此感兴趣 method get_waiter(waiter_name). Examples of waiters are in this page。我找遍了所有地方,但找不到此特定服务的完整服务员列表(Python 和 PHP)。

基本上,我想要做的是获取应用程序或环境的状态并在继续下一个任务之前验证它是否良好。

我目前的方法是使用 while 循环和 break 如果来自 AWS 响应的状态与我预期的状态相匹配。我认为这不是处理此问题的最佳方法。如有错误请指正

这是我在 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

该服务还没有服务员。如果有,您会在文档中看到它们。例如比较 elasticbeanstalk boto3 docs with the cloudfront docs. The cloudfront docs have a waiters section.