AWS: check dbname attribute before accessing (#46253)

Check dbname attribute in instance before accessing it in RDS module

Fixes: #38210

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-10-05 15:37:34 -05:00 committed by Ryan Brown
parent a4c9f57b38
commit e5878d19de

View file

@ -716,8 +716,7 @@ class RDSDBInstance:
d["endpoint"] = None
d["port"] = None
d["vpc_security_groups"] = None
if self.instance.DBName:
d['DBName'] = self.instance.DBName
d['DBName'] = self.instance.DBName if hasattr(self.instance, 'DBName') else None
# ReadReplicaSourceDBInstanceIdentifier may or may not exist
try:
d["replication_source"] = self.instance.ReadReplicaSourceDBInstanceIdentifier
@ -810,8 +809,7 @@ class RDS2DBInstance:
else:
d['endpoint'] = None
d['port'] = None
if self.instance["DBName"]:
d['DBName'] = self.instance['DBName']
d['DBName'] = self.instance['DBName'] if hasattr(self.instance, 'DBName') else None
return d