diff --git a/barman/cloud_providers/__init__.py b/barman/cloud_providers/__init__.py index b02ad4611..02cf8f614 100644 --- a/barman/cloud_providers/__init__.py +++ b/barman/cloud_providers/__init__.py @@ -16,8 +16,12 @@ # You should have received a copy of the GNU General Public License # along with Barman. If not, see +import logging + from barman.exceptions import BarmanException, ConfigurationException +_logger = logging.getLogger(__name__) + class CloudProviderUnsupported(BarmanException): """ @@ -333,19 +337,29 @@ def get_snapshot_interface_from_backup_info(backup_info, config=None): # from the backup_info, unless a region is set in the config in which case the # config region takes precedence. region = None + profile = None + aws_irsa = False if config is not None: if hasattr(config, "aws_region"): region = config.aws_region try: - if getattr(config, "aws_profile"): - profile = config.aws_profile + if getattr(config, "aws_irsa"): + aws_irsa = config.aws_irsa except AttributeError: - raise SystemExit( - "Unable to locate credentials. You should configure an AWS profile." + _logger.warning( + "Unable to locate iam role. Trying aws profile." ) + else: + try: + if getattr(config, "aws_profile"): + profile = config.aws_profile + except AttributeError: + raise SystemExit( + "Unable to locate credentials. You should configure an AWS IAM role or an AWS profile." + ) if region is None: region = backup_info.snapshots_info.region - return AwsCloudSnapshotInterface(profile, region) + return AwsCloudSnapshotInterface(profile, aws_irsa, region) else: raise CloudProviderUnsupported( "Unsupported snapshot provider in backup info: %s"