diff --git a/cloudwash/providers/aws.py b/cloudwash/providers/aws.py index ef7f0b557..17b90a3ab 100644 --- a/cloudwash/providers/aws.py +++ b/cloudwash/providers/aws.py @@ -5,7 +5,7 @@ from cloudwash.utils import dry_data from cloudwash.utils import echo_dry from cloudwash.utils import total_running_time - +import sys def cleanup(**kwargs): @@ -13,8 +13,18 @@ def cleanup(**kwargs): data = ['VMS', 'NICS', 'DISCS', 'PIPS', 'RESOURCES', 'STACKS'] regions = settings.aws.auth.regions if "all" in regions: - with compute_client("aws", aws_region="us-west-2") as client: - regions = client.list_regions() + default_regions = ['us-west-2', 'cn-northwest-1', 'us-gov-west-1'] + for region in default_regions: + try: + with compute_client("aws", aws_region=region) as client: + regions = client.list_regions() + if regions: + break + except Exception as e: + pass + if "all" in regions: + logger.error(f"Unable to retrive region list using currrent token!") + sys.exit(1) for region in regions: dry_data['VMS']['stop'] = [] dry_data['VMS']['skip'] = []