From e00f5ee0c26270e4c619d891988556f1ef38073b Mon Sep 17 00:00:00 2001 From: Tyler Ramsbey <86263907+TeneBrae93@users.noreply.github.com> Date: Tue, 4 Jun 2024 15:35:28 -0500 Subject: [PATCH] Update main.py - I broke error handling in my last commit when targeting multiple regions -- this fixes that --- pacu/modules/apigateway__enum/main.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pacu/modules/apigateway__enum/main.py b/pacu/modules/apigateway__enum/main.py index 96a17624..9517be8a 100644 --- a/pacu/modules/apigateway__enum/main.py +++ b/pacu/modules/apigateway__enum/main.py @@ -136,10 +136,24 @@ def main(args, pacu_main: "Main"): client = pacu_main.get_boto3_client('apigateway', region) print(f"Enumerating {region}") - summary_data['apiKeys'] = get_api_keys(client) - summary_data['clientCerts'] = get_client_certs(client) + # Get global API data + try: + summary_data['apiKeys'] = get_api_keys(client) + except Exception as e: + print(f"Failed to get API Keys in {region}: {e}") + try: + summary_data['clientCerts'] = get_client_certs(client) + except Exception as e: + print(f"Failed to get Client Certs in {region}: {e}") + + # Currently this only supports REST apis + # Get all apis in AWS Gatway + try: + response = client.get_rest_apis() + except Exception as e: + print(f"Failed to get APIs in {region}: {e}") + continue - response = client.get_rest_apis() items = response['items'] for api in items: