From 4eaa666c3b7c9fa8ff77baaad29b1e6abe108884 Mon Sep 17 00:00:00 2001 From: Daniel Barranquero <74871504+danibarranqueroo@users.noreply.github.com> Date: Fri, 6 Dec 2024 13:35:29 +0100 Subject: [PATCH] fix(backup): modify list recovery points call (#5996) (cherry picked from commit 2ce8e1fd21796dbd1291cd0642330b9068537e97) --- .../aws/services/backup/backup_service.py | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/prowler/providers/aws/services/backup/backup_service.py b/prowler/providers/aws/services/backup/backup_service.py index 4805e362590..8690ae4ecc2 100644 --- a/prowler/providers/aws/services/backup/backup_service.py +++ b/prowler/providers/aws/services/backup/backup_service.py @@ -183,21 +183,26 @@ def _list_tags(self, resource): def _list_recovery_points(self, regional_client): logger.info("Backup - Listing Recovery Points...") try: - for backup_vault in self.backup_vaults: - paginator = regional_client.get_paginator( - "list_recovery_points_by_backup_vault" - ) - for page in paginator.paginate(BackupVaultName=backup_vault.name): - for recovery_point in page.get("RecoveryPoints", []): - self.recovery_points.append( - RecoveryPoint( - arn=recovery_point.get("RecoveryPointArn"), - backup_vault_name=backup_vault.name, - encrypted=recovery_point.get("IsEncrypted", False), - backup_vault_region=backup_vault.region, - tags=[], - ) - ) + if self.backup_vaults: + for backup_vault in self.backup_vaults: + paginator = regional_client.get_paginator( + "list_recovery_points_by_backup_vault" + ) + for page in paginator.paginate(BackupVaultName=backup_vault.name): + for recovery_point in page.get("RecoveryPoints", []): + arn = recovery_point.get("RecoveryPointArn") + if arn: + self.recovery_points.append( + RecoveryPoint( + arn=arn, + backup_vault_name=backup_vault.name, + encrypted=recovery_point.get( + "IsEncrypted", False + ), + backup_vault_region=backup_vault.region, + tags=[], + ) + ) except ClientError as error: logger.error( f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"