Quellcode durchsuchen

boto3 has the key_material field only if data exists

Enis Afgan vor 8 Jahren
Ursprung
Commit
8a66c5a7b5
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 5 1
      cloudbridge/cloud/providers/aws/resources.py

+ 5 - 1
cloudbridge/cloud/providers/aws/resources.py

@@ -537,7 +537,11 @@ class AWSKeyPair(BaseKeyPair):
 
     @property
     def material(self):
-        return self._key_pair.key_material
+        # boto3 object will only have this field if the value is not empty
+        if hasattr(self._key_pair, 'key_material'):
+            return self._key_pair.key_material
+        else:
+            return None
 
 
 class AWSSecurityGroup(BaseSecurityGroup):