Skip to content

Commit 8c35a87

Browse files
committed
Proposed fix for issue #5
1 parent de87960 commit 8c35a87

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lambda/backuplambda.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,22 @@ def snapshot_resource(self, resource, description, tags):
324324
date = datetime.today().strftime('%d-%m-%Y-%H-%M-%S')
325325
snapshot_id = self.period+'-'+self.resolve_backupable_id(resource)+"-"+date+"-"+self.date_suffix
326326

327-
current_snap = self.conn.create_db_snapshot(DBInstanceIdentifier=self.resolve_backupable_id(resource),
328-
DBSnapshotIdentifier=snapshot_id,
329-
Tags=aws_tagset)
327+
if is_cluster(resource):
328+
current_snap = self.conn.create_db_cluster_snapshot(
329+
DBClusterIdentifier=self.resolve_backupable_id(resource),
330+
DBClusterSnapshotIdentifier=snapshot_id,
331+
Tags=aws_tagset)
332+
else:
333+
current_snap = self.conn.create_db_snapshot(
334+
DBInstanceIdentifier=self.resolve_backupable_id(resource),
335+
DBSnapshotIdentifier=snapshot_id,
336+
Tags=aws_tagset)
337+
338+
def is_cluster(self, resource):
339+
try:
340+
return resource['DBClusterIdentifier'] is not None
341+
except:
342+
return False
330343

331344
def list_snapshots_for_resource(self, resource):
332345
snapshots = self.conn.describe_db_snapshots(DBInstanceIdentifier=self.resolve_backupable_id(resource),

0 commit comments

Comments
 (0)