{
  "output": "Successfully created and wrote to new file: /Users/bob/git/dxw/aws-stuff/audit.py. Here is the updated code:\nimport argparse\nimport sys\nimport importlib.util\nimport os\n\n# Audits mapping: command -> (module_name, file_path)\nAUDITS = {\n    \"vpc\": (\"audits.vpc\", \"audits/vpc.py\"),\n    \"cost\": (\"aws_cost\", \"aws_cost.py\"),\n    \"bills\": (\"aws_bills\", \"aws_bills.py\"),\n    \"bw\": (\"bwsuage\", \"bwsuage.py\"),\n    \"storage\": (\"storage_usage\", \"storage-usage.py\"),\n    \"rds\": (\"list_rds_instances\", \"list_rds_instances.py\"),\n    \"asg\": (\"aws_asg_lt_ami\", \"aws-asg-lt-ami.py\"),\n    \"ips\": (\"aws_ips\", \"aws-ips.py\"),\n    \"cloudfront\": (\"cloudfront\", \"cloudfront.py\"),\n    \"s3\": (\"s3_security_audit\", \"s3-security-audit.py\"),\n    \"sg\": (\"security_group_audit\", \"security-group-audit.py\"),\n    \"iam\": (\"iam_audit\", \"iam-audit.py\"),\n    \"carbon\": (\"aws_carbon\", \"aws-carbon.py\"),\n    \"metrics\": (\"aws_metrics\", \"aws-metrics.py\"),\n}\n\ndef run_audit(name):\n    if name not in AUDITS:\n        print(f\"Error: Unknown audit '{name}'\")\n        print_usage()\n        sys.exit(1)\n        \n    module_name, file_path = AUDITS[name]\n    \n    if not os.path.exists(file_path):\n        print(f\"Error: File not found for audit '{name}': {file_path}\")\n        sys.exit(1)\n        \n    print(f\"Running audit: {name}...\")\n    \n    # Import and run the module\n    spec = importlib.util.spec_from_file_location(module_name, file_path)\n    module = importlib.util.module_from_spec(spec)\n    sys.modules[module_name] = module\n    spec.loader.exec_module(module)\n    \n    # Check if there's a 'run' or 'main' function\n    if hasattr(module, \"run\"):\n        module.run()\n    elif hasattr(module, \"main\"):\n        module.main()\n    else:\n        print(f\"Error: Audit '{name}' (in {file_path}) does not have a run() or main() function.\")\n        sys.exit(1)\n\ndef print_usage():\n    print(\"\\nAvailable audits:\")\n    for name in sorted(AUDITS.keys()):\n        print(f\"  - {name}\")\n\ndef main():\n    parser = argparse.ArgumentParser(description=\"AWS Organization Audit CLI\")\n    parser.add_argument(\"audit\", nargs=\"?\", help=\"Name of the audit to run\")\n    parser.add_argument(\"--list\", action=\"store_true\", help=\"List available audits\")\n    \n    args = parser.parse_args()\n    \n    if args.list or not args.audit:\n        print_usage()\n        return\n        \n    run_audit(args.audit)\n\nif __name__ == \"__main__\":\n    main()\n"
}