From a21dd4a2edba945fe4730f6ba01e74205bfe327d Mon Sep 17 00:00:00 2001 From: Antoine Ansari <49979277+Mohsen51@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:05:45 +0100 Subject: [PATCH] feat(quick-inventory): custom output file in quick inventory (#3306) Co-authored-by: antoinea --- .../aws/lib/quick_inventory/quick_inventory.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/prowler/providers/aws/lib/quick_inventory/quick_inventory.py b/prowler/providers/aws/lib/quick_inventory/quick_inventory.py index 666c2896..81c51487 100644 --- a/prowler/providers/aws/lib/quick_inventory/quick_inventory.py +++ b/prowler/providers/aws/lib/quick_inventory/quick_inventory.py @@ -211,9 +211,13 @@ def create_inventory_table(resources: list, resources_in_region: dict) -> dict: def create_output(resources: list, audit_info: AWS_Audit_Info, args): json_output = [] - output_file = ( - f"prowler-inventory-{audit_info.audited_account}-{output_file_timestamp}" - ) + # Check if custom output filename was input, if not, set the default + if not hasattr(args, "output_filename") or args.output_filename is None: + output_file = ( + f"prowler-inventory-{audit_info.audited_account}-{output_file_timestamp}" + ) + else: + output_file = args.output_filename for item in sorted(resources, key=lambda d: d["arn"]): resource = {}