Skip to content

Commit c8a5605

Browse files
aBurmeseDevscmacdon
authored andcommitted
add clean up resources for when scenario fails
1 parent 79a1954 commit c8a5605

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

python/example_code/s3/scenarios/batch/s3_batch_scenario.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ def run_scenario(self) -> None:
176176

177177
except Exception as e:
178178
print(f"An error occurred: {e}")
179+
print("\nCleaning up resources due to failure...")
180+
try:
181+
self.s3_batch_wrapper.cleanup_resources(bucket_name, file_names)
182+
self.cfn_helper.destroy_cloudformation_stack(self.STACK_NAME)
183+
except Exception as cleanup_error:
184+
print(f"Error during cleanup: {cleanup_error}")
179185
raise
180186

181187
print("\nThe Amazon S3 Batch scenario has successfully completed.")

0 commit comments

Comments
 (0)