<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_connection(url):
 """ Build an Elasticsearch connection with the given url Elastic.co's Heroku addon doesn't create credientials with access to the cluster by default so they aren't exposed in the URL they provide either. This function works around the situation by grabbing our credentials from the environment via Django settings and building a connection with them. """

    username = os.environ.get('ELASTICSEARCH_USERNAME')
    password = os.environ.get('ELASTICSEARCH_PASSWORD')

    if username and password:
        return Elasticsearch(url, http_auth=(username, password))

    return Elasticsearch(url)