diff --git a/health/healthcheck.py b/health/healthcheck.py index 11a365e34..98de22435 100644 --- a/health/healthcheck.py +++ b/health/healthcheck.py @@ -77,10 +77,11 @@ class LocalHealthCheck(HealthCheck): class ProductionHealthCheck(HealthCheck): - def __init__(self, app, access_key, secret_key): + def __init__(self, app, access_key, secret_key, db_instance='quay'): super(ProductionHealthCheck, self).__init__(app) self.access_key = access_key self.secret_key = secret_key + self.db_instance = db_instance @classmethod def check_name(cls): @@ -115,7 +116,10 @@ class ProductionHealthCheck(HealthCheck): aws_access_key_id=self.access_key, aws_secret_access_key=self.secret_key) response = region.describe_db_instances()['DescribeDBInstancesResponse'] result = response['DescribeDBInstancesResult'] - instances = result['DBInstances'] + instances = [i for i in result['DBInstances'] if i['DBInstanceIdentifier'] == self.db_instance] + if not instances: + return 'error' + status = instances[0]['DBInstanceStatus'] return status except: