Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add region error handling to cloudformation download data module #409

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading