Skip to content

Commit

Permalink
Merge pull request #409 from RhinoSecurityLabs/fix/cloudformation-dow…
Browse files Browse the repository at this point in the history
…nload-data-module. closes #408

Add region error handling to cloudformation download data module.
  • Loading branch information
DaveYesland authored Mar 6, 2024
2 parents c7e3cfb + f954ac6 commit 3bd8aac
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pacu/modules/cloudformation__download_data/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ def default(self, obj):
all_stacks = []
found_regions = []
for region in regions:
client = pacu_main.get_boto3_client('cloudformation', region)
print('Looking for CloudFormation Stacks in region {}...'.format(region))
stacks_data = client.describe_stacks()
stacks = stacks_data['Stacks']
all_stacks += stacks

if stacks_data['Stacks']:
print('Getting exports for region: {}'.format(region))
try:
client = pacu_main.get_boto3_client("cloudformation", region)
print("Looking for CloudFormation Stacks in region {}...".format(region))
stacks_data = client.describe_stacks()
stacks = stacks_data["Stacks"]
all_stacks += stacks
except ClientError as e:
print(f"Error: Could not enumerate region {region}")
print(f"Error: {e}")
continue
exports = client.list_exports()
if exports:
with outfile('exports', region) as (f):
Expand Down

0 comments on commit 3bd8aac

Please sign in to comment.