AWS SDK | List of waiters for Elastic Beanstalk
<p>I'm interested in this <a href="https://boto3.readthedocs.io/en/latest/reference/services/elasticbeanstalk.html#ElasticBeanstalk.Client.get_waiter" rel="nofollow">method</a> <code>get_waiter(waiter_name)</code>. Examples of waiters are in this <a href="http://boto3.readthedocs.io/en/latest/guide/clients.html#waiters" rel="nofollow">page</a>. I looked everywhere but I couldn't find a complete list of waiters for this particular service (for Python and PHP as well). </p>

<p>Basically, what I want to happen is to get the status of app or environment and verify it's good before moving on to the next task.</p>

<p>My current approach is to use <code>while</code> loop and <code>break</code> if the status from AWS response matches the status that I was expecting. I think this is not the best way to deal with this. Please correct me if I'm wrong.</p>

<p>Here's the snippet from my code written in Python:</p>

<pre><code># 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
</code></pre>

<p>There are no waiters for that service yet. If there were, you would see them in the docs. For example compare the <a href="http://boto3.readthedocs.io/en/latest/reference/services/elasticbeanstalk.html" rel="nofollow">elasticbeanstalk boto3 docs</a> with the <a href="http://boto3.readthedocs.io/en/latest/reference/services/cloudfront.html" rel="nofollow">cloudfront docs</a>. The cloudfront docs have a <a href="http://boto3.readthedocs.io/en/latest/reference/services/cloudfront.html#waiters" rel="nofollow">waiters section</a>.</p>

python amazon-web-services sdk boto