runbooks 0.2.5__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. conftest.py +26 -0
  2. jupyter-agent/.env +2 -0
  3. jupyter-agent/.env.template +2 -0
  4. jupyter-agent/.gitattributes +35 -0
  5. jupyter-agent/.gradio/certificate.pem +31 -0
  6. jupyter-agent/README.md +16 -0
  7. jupyter-agent/__main__.log +8 -0
  8. jupyter-agent/app.py +256 -0
  9. jupyter-agent/cloudops-agent.png +0 -0
  10. jupyter-agent/ds-system-prompt.txt +154 -0
  11. jupyter-agent/jupyter-agent.png +0 -0
  12. jupyter-agent/llama3_template.jinja +123 -0
  13. jupyter-agent/requirements.txt +9 -0
  14. jupyter-agent/tmp/4ojbs8a02ir/jupyter-agent.ipynb +68 -0
  15. jupyter-agent/tmp/cm5iasgpm3p/jupyter-agent.ipynb +91 -0
  16. jupyter-agent/tmp/crqbsseag5/jupyter-agent.ipynb +91 -0
  17. jupyter-agent/tmp/hohanq1u097/jupyter-agent.ipynb +57 -0
  18. jupyter-agent/tmp/jns1sam29wm/jupyter-agent.ipynb +53 -0
  19. jupyter-agent/tmp/jupyter-agent.ipynb +27 -0
  20. jupyter-agent/utils.py +409 -0
  21. runbooks/__init__.py +71 -3
  22. runbooks/__main__.py +13 -0
  23. runbooks/aws/ec2_describe_instances.py +1 -1
  24. runbooks/aws/ec2_run_instances.py +8 -2
  25. runbooks/aws/ec2_start_stop_instances.py +17 -4
  26. runbooks/aws/ec2_unused_volumes.py +5 -1
  27. runbooks/aws/s3_create_bucket.py +4 -2
  28. runbooks/aws/s3_list_objects.py +6 -1
  29. runbooks/aws/tagging_lambda_handler.py +13 -2
  30. runbooks/aws/tags.json +12 -0
  31. runbooks/base.py +353 -0
  32. runbooks/cfat/README.md +49 -0
  33. runbooks/cfat/__init__.py +74 -0
  34. runbooks/cfat/app.ts +644 -0
  35. runbooks/cfat/assessment/__init__.py +40 -0
  36. runbooks/cfat/assessment/asana-import.csv +39 -0
  37. runbooks/cfat/assessment/cfat-checks.csv +31 -0
  38. runbooks/cfat/assessment/cfat.txt +520 -0
  39. runbooks/cfat/assessment/collectors.py +200 -0
  40. runbooks/cfat/assessment/jira-import.csv +39 -0
  41. runbooks/cfat/assessment/runner.py +387 -0
  42. runbooks/cfat/assessment/validators.py +290 -0
  43. runbooks/cfat/cli.py +103 -0
  44. runbooks/cfat/docs/asana-import.csv +24 -0
  45. runbooks/cfat/docs/cfat-checks.csv +31 -0
  46. runbooks/cfat/docs/cfat.txt +335 -0
  47. runbooks/cfat/docs/checks-output.png +0 -0
  48. runbooks/cfat/docs/cloudshell-console-run.png +0 -0
  49. runbooks/cfat/docs/cloudshell-download.png +0 -0
  50. runbooks/cfat/docs/cloudshell-output.png +0 -0
  51. runbooks/cfat/docs/downloadfile.png +0 -0
  52. runbooks/cfat/docs/jira-import.csv +24 -0
  53. runbooks/cfat/docs/open-cloudshell.png +0 -0
  54. runbooks/cfat/docs/report-header.png +0 -0
  55. runbooks/cfat/models.py +1026 -0
  56. runbooks/cfat/package-lock.json +5116 -0
  57. runbooks/cfat/package.json +38 -0
  58. runbooks/cfat/report.py +496 -0
  59. runbooks/cfat/reporting/__init__.py +46 -0
  60. runbooks/cfat/reporting/exporters.py +337 -0
  61. runbooks/cfat/reporting/formatters.py +496 -0
  62. runbooks/cfat/reporting/templates.py +135 -0
  63. runbooks/cfat/run-assessment.sh +23 -0
  64. runbooks/cfat/runner.py +69 -0
  65. runbooks/cfat/src/actions/check-cloudtrail-existence.ts +43 -0
  66. runbooks/cfat/src/actions/check-config-existence.ts +37 -0
  67. runbooks/cfat/src/actions/check-control-tower.ts +37 -0
  68. runbooks/cfat/src/actions/check-ec2-existence.ts +46 -0
  69. runbooks/cfat/src/actions/check-iam-users.ts +50 -0
  70. runbooks/cfat/src/actions/check-legacy-cur.ts +30 -0
  71. runbooks/cfat/src/actions/check-org-cloudformation.ts +30 -0
  72. runbooks/cfat/src/actions/check-vpc-existence.ts +43 -0
  73. runbooks/cfat/src/actions/create-asanaimport.ts +14 -0
  74. runbooks/cfat/src/actions/create-backlog.ts +372 -0
  75. runbooks/cfat/src/actions/create-jiraimport.ts +15 -0
  76. runbooks/cfat/src/actions/create-report.ts +616 -0
  77. runbooks/cfat/src/actions/define-account-type.ts +51 -0
  78. runbooks/cfat/src/actions/get-enabled-org-policy-types.ts +40 -0
  79. runbooks/cfat/src/actions/get-enabled-org-services.ts +26 -0
  80. runbooks/cfat/src/actions/get-idc-info.ts +34 -0
  81. runbooks/cfat/src/actions/get-org-da-accounts.ts +34 -0
  82. runbooks/cfat/src/actions/get-org-details.ts +35 -0
  83. runbooks/cfat/src/actions/get-org-member-accounts.ts +44 -0
  84. runbooks/cfat/src/actions/get-org-ous.ts +35 -0
  85. runbooks/cfat/src/actions/get-regions.ts +22 -0
  86. runbooks/cfat/src/actions/zip-assessment.ts +27 -0
  87. runbooks/cfat/src/types/index.d.ts +147 -0
  88. runbooks/cfat/tests/__init__.py +141 -0
  89. runbooks/cfat/tests/test_cli.py +340 -0
  90. runbooks/cfat/tests/test_integration.py +290 -0
  91. runbooks/cfat/tests/test_models.py +505 -0
  92. runbooks/cfat/tests/test_reporting.py +354 -0
  93. runbooks/cfat/tsconfig.json +16 -0
  94. runbooks/cfat/webpack.config.cjs +27 -0
  95. runbooks/config.py +260 -0
  96. runbooks/finops/README.md +337 -0
  97. runbooks/finops/__init__.py +86 -0
  98. runbooks/finops/aws_client.py +245 -0
  99. runbooks/finops/cli.py +151 -0
  100. runbooks/finops/cost_processor.py +410 -0
  101. runbooks/finops/dashboard_runner.py +448 -0
  102. runbooks/finops/helpers.py +355 -0
  103. runbooks/finops/main.py +14 -0
  104. runbooks/finops/profile_processor.py +174 -0
  105. runbooks/finops/types.py +66 -0
  106. runbooks/finops/visualisations.py +80 -0
  107. runbooks/inventory/.gitignore +354 -0
  108. runbooks/inventory/ArgumentsClass.py +261 -0
  109. runbooks/inventory/FAILED_SCRIPTS_TROUBLESHOOTING.md +619 -0
  110. runbooks/inventory/Inventory_Modules.py +6130 -0
  111. runbooks/inventory/LandingZone/delete_lz.py +1075 -0
  112. runbooks/inventory/PASSED_SCRIPTS_GUIDE.md +738 -0
  113. runbooks/inventory/README.md +1320 -0
  114. runbooks/inventory/__init__.py +62 -0
  115. runbooks/inventory/account_class.py +532 -0
  116. runbooks/inventory/all_my_instances_wrapper.py +123 -0
  117. runbooks/inventory/aws_decorators.py +201 -0
  118. runbooks/inventory/aws_organization.png +0 -0
  119. runbooks/inventory/cfn_move_stack_instances.py +1526 -0
  120. runbooks/inventory/check_cloudtrail_compliance.py +614 -0
  121. runbooks/inventory/check_controltower_readiness.py +1107 -0
  122. runbooks/inventory/check_landingzone_readiness.py +711 -0
  123. runbooks/inventory/cloudtrail.md +727 -0
  124. runbooks/inventory/collectors/__init__.py +20 -0
  125. runbooks/inventory/collectors/aws_compute.py +518 -0
  126. runbooks/inventory/collectors/aws_networking.py +275 -0
  127. runbooks/inventory/collectors/base.py +222 -0
  128. runbooks/inventory/core/__init__.py +19 -0
  129. runbooks/inventory/core/collector.py +303 -0
  130. runbooks/inventory/core/formatter.py +296 -0
  131. runbooks/inventory/delete_s3_buckets_objects.py +169 -0
  132. runbooks/inventory/discovery.md +81 -0
  133. runbooks/inventory/draw_org_structure.py +748 -0
  134. runbooks/inventory/ec2_vpc_utils.py +341 -0
  135. runbooks/inventory/find_cfn_drift_detection.py +272 -0
  136. runbooks/inventory/find_cfn_orphaned_stacks.py +719 -0
  137. runbooks/inventory/find_cfn_stackset_drift.py +733 -0
  138. runbooks/inventory/find_ec2_security_groups.py +669 -0
  139. runbooks/inventory/find_landingzone_versions.py +201 -0
  140. runbooks/inventory/find_vpc_flow_logs.py +1221 -0
  141. runbooks/inventory/inventory.sh +659 -0
  142. runbooks/inventory/list_cfn_stacks.py +558 -0
  143. runbooks/inventory/list_cfn_stackset_operation_results.py +252 -0
  144. runbooks/inventory/list_cfn_stackset_operations.py +734 -0
  145. runbooks/inventory/list_cfn_stacksets.py +453 -0
  146. runbooks/inventory/list_config_recorders_delivery_channels.py +681 -0
  147. runbooks/inventory/list_ds_directories.py +354 -0
  148. runbooks/inventory/list_ec2_availability_zones.py +286 -0
  149. runbooks/inventory/list_ec2_ebs_volumes.py +244 -0
  150. runbooks/inventory/list_ec2_instances.py +425 -0
  151. runbooks/inventory/list_ecs_clusters_and_tasks.py +562 -0
  152. runbooks/inventory/list_elbs_load_balancers.py +411 -0
  153. runbooks/inventory/list_enis_network_interfaces.py +526 -0
  154. runbooks/inventory/list_guardduty_detectors.py +568 -0
  155. runbooks/inventory/list_iam_policies.py +404 -0
  156. runbooks/inventory/list_iam_roles.py +518 -0
  157. runbooks/inventory/list_iam_saml_providers.py +359 -0
  158. runbooks/inventory/list_lambda_functions.py +882 -0
  159. runbooks/inventory/list_org_accounts.py +446 -0
  160. runbooks/inventory/list_org_accounts_users.py +354 -0
  161. runbooks/inventory/list_rds_db_instances.py +406 -0
  162. runbooks/inventory/list_route53_hosted_zones.py +318 -0
  163. runbooks/inventory/list_servicecatalog_provisioned_products.py +575 -0
  164. runbooks/inventory/list_sns_topics.py +360 -0
  165. runbooks/inventory/list_ssm_parameters.py +402 -0
  166. runbooks/inventory/list_vpc_subnets.py +433 -0
  167. runbooks/inventory/list_vpcs.py +422 -0
  168. runbooks/inventory/lockdown_cfn_stackset_role.py +224 -0
  169. runbooks/inventory/models/__init__.py +24 -0
  170. runbooks/inventory/models/account.py +192 -0
  171. runbooks/inventory/models/inventory.py +309 -0
  172. runbooks/inventory/models/resource.py +247 -0
  173. runbooks/inventory/recover_cfn_stack_ids.py +205 -0
  174. runbooks/inventory/requirements.txt +12 -0
  175. runbooks/inventory/run_on_multi_accounts.py +211 -0
  176. runbooks/inventory/tests/common_test_data.py +3661 -0
  177. runbooks/inventory/tests/common_test_functions.py +204 -0
  178. runbooks/inventory/tests/setup.py +24 -0
  179. runbooks/inventory/tests/src.py +18 -0
  180. runbooks/inventory/tests/test_cfn_describe_stacks.py +208 -0
  181. runbooks/inventory/tests/test_ec2_describe_instances.py +162 -0
  182. runbooks/inventory/tests/test_inventory_modules.py +55 -0
  183. runbooks/inventory/tests/test_lambda_list_functions.py +86 -0
  184. runbooks/inventory/tests/test_moto_integration_example.py +273 -0
  185. runbooks/inventory/tests/test_org_list_accounts.py +49 -0
  186. runbooks/inventory/update_aws_actions.py +173 -0
  187. runbooks/inventory/update_cfn_stacksets.py +1215 -0
  188. runbooks/inventory/update_cloudwatch_logs_retention_policy.py +294 -0
  189. runbooks/inventory/update_iam_roles_cross_accounts.py +478 -0
  190. runbooks/inventory/update_s3_public_access_block.py +539 -0
  191. runbooks/inventory/utils/__init__.py +23 -0
  192. runbooks/inventory/utils/aws_helpers.py +510 -0
  193. runbooks/inventory/utils/threading_utils.py +493 -0
  194. runbooks/inventory/utils/validation.py +682 -0
  195. runbooks/inventory/verify_ec2_security_groups.py +1430 -0
  196. runbooks/main.py +1004 -0
  197. runbooks/organizations/__init__.py +12 -0
  198. runbooks/organizations/manager.py +374 -0
  199. runbooks/security/README.md +447 -0
  200. runbooks/security/__init__.py +71 -0
  201. runbooks/{security_baseline → security}/checklist/alternate_contacts.py +8 -1
  202. runbooks/{security_baseline → security}/checklist/bucket_public_access.py +4 -1
  203. runbooks/{security_baseline → security}/checklist/cloudwatch_alarm_configuration.py +9 -2
  204. runbooks/{security_baseline → security}/checklist/guardduty_enabled.py +9 -2
  205. runbooks/{security_baseline → security}/checklist/multi_region_instance_usage.py +5 -1
  206. runbooks/{security_baseline → security}/checklist/root_access_key.py +6 -1
  207. runbooks/{security_baseline → security}/config-origin.json +1 -1
  208. runbooks/{security_baseline → security}/config.json +1 -1
  209. runbooks/{security_baseline → security}/permission.json +1 -1
  210. runbooks/{security_baseline → security}/report_generator.py +10 -2
  211. runbooks/{security_baseline → security}/report_template_en.html +7 -7
  212. runbooks/{security_baseline → security}/report_template_jp.html +7 -7
  213. runbooks/{security_baseline → security}/report_template_kr.html +12 -12
  214. runbooks/{security_baseline → security}/report_template_vn.html +7 -7
  215. runbooks/{security_baseline → security}/run_script.py +8 -2
  216. runbooks/{security_baseline → security}/security_baseline_tester.py +12 -4
  217. runbooks/{security_baseline → security}/utils/common.py +5 -1
  218. runbooks/utils/__init__.py +204 -0
  219. runbooks-0.7.0.dist-info/METADATA +375 -0
  220. runbooks-0.7.0.dist-info/RECORD +249 -0
  221. {runbooks-0.2.5.dist-info → runbooks-0.7.0.dist-info}/WHEEL +1 -1
  222. runbooks-0.7.0.dist-info/entry_points.txt +7 -0
  223. runbooks-0.7.0.dist-info/licenses/LICENSE +201 -0
  224. runbooks-0.7.0.dist-info/top_level.txt +3 -0
  225. runbooks/python101/calculator.py +0 -34
  226. runbooks/python101/config.py +0 -1
  227. runbooks/python101/exceptions.py +0 -16
  228. runbooks/python101/file_manager.py +0 -218
  229. runbooks/python101/toolkit.py +0 -153
  230. runbooks-0.2.5.dist-info/METADATA +0 -439
  231. runbooks-0.2.5.dist-info/RECORD +0 -61
  232. runbooks-0.2.5.dist-info/entry_points.txt +0 -3
  233. runbooks-0.2.5.dist-info/top_level.txt +0 -1
  234. /runbooks/{security_baseline/__init__.py → inventory/tests/script_test_data.py} +0 -0
  235. /runbooks/{security_baseline → security}/checklist/__init__.py +0 -0
  236. /runbooks/{security_baseline → security}/checklist/account_level_bucket_public_access.py +0 -0
  237. /runbooks/{security_baseline → security}/checklist/direct_attached_policy.py +0 -0
  238. /runbooks/{security_baseline → security}/checklist/iam_password_policy.py +0 -0
  239. /runbooks/{security_baseline → security}/checklist/iam_user_mfa.py +0 -0
  240. /runbooks/{security_baseline → security}/checklist/multi_region_trail.py +0 -0
  241. /runbooks/{security_baseline → security}/checklist/root_mfa.py +0 -0
  242. /runbooks/{security_baseline → security}/checklist/root_usage.py +0 -0
  243. /runbooks/{security_baseline → security}/checklist/trail_enabled.py +0 -0
  244. /runbooks/{security_baseline → security}/checklist/trusted_advisor.py +0 -0
  245. /runbooks/{security_baseline → security}/utils/__init__.py +0 -0
  246. /runbooks/{security_baseline → security}/utils/enums.py +0 -0
  247. /runbooks/{security_baseline → security}/utils/language.py +0 -0
  248. /runbooks/{security_baseline → security}/utils/level_const.py +0 -0
  249. /runbooks/{security_baseline → security}/utils/permission_list.py +0 -0
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ AWS S3 Bucket Object Deletion and Bucket Management Tool
4
+
5
+ A specialized utility for safely emptying and optionally deleting S3 buckets,
6
+ including all object versions and delete markers. Essential for bucket lifecycle
7
+ management and compliance with data retention policies.
8
+
9
+ **AWS API Mapping**:
10
+ - `boto3.resource('s3').Bucket.object_versions.delete()`
11
+ - `boto3.resource('s3').Bucket.delete()`
12
+
13
+ **SECURITY WARNING**: This script performs DESTRUCTIVE operations:
14
+ - Permanently deletes ALL objects and versions from specified bucket
15
+ - Can delete the bucket itself with --force-delete flag
16
+ - Cannot be undone - ensure proper backups before execution
17
+ - May affect compliance with data retention requirements
18
+
19
+ Features:
20
+ - Complete object version deletion (including delete markers)
21
+ - Interactive bucket deletion confirmation
22
+ - Force deletion mode for automation scenarios
23
+ - Comprehensive error handling and logging
24
+ - Single-bucket targeted operation for safety
25
+
26
+ Security Controls:
27
+ - Requires explicit bucket name parameter
28
+ - Interactive confirmation for bucket deletion
29
+ - Force flag available for automated scenarios
30
+ - Detailed logging of all destructive operations
31
+
32
+ Compliance Considerations:
33
+ - Verify data retention policy compliance before execution
34
+ - Ensure proper backup procedures are in place
35
+ - Document destruction for audit trails
36
+ - Consider legal hold and litigation requirements
37
+
38
+ Example:
39
+ Empty bucket but keep it:
40
+ ```bash
41
+ python delete_s3_buckets_objects.py --profile my-profile --bucket my-bucket
42
+ ```
43
+
44
+ Empty and delete bucket with confirmation:
45
+ ```bash
46
+ python delete_s3_buckets_objects.py --profile my-profile --bucket my-bucket +delete
47
+ ```
48
+
49
+ Requirements:
50
+ - IAM permissions: `s3:DeleteObject`, `s3:DeleteObjectVersion`, `s3:DeleteBucket`
51
+ - Bucket must be in accessible region
52
+ - Python 3.8+ with required dependencies
53
+
54
+ Author:
55
+ AWS Cloud Foundations Team
56
+
57
+ Version:
58
+ 2023.05.04
59
+ """
60
+
61
+ import logging
62
+
63
+ from account_class import aws_acct_access
64
+ from ArgumentsClass import CommonArguments
65
+
66
+ __version__ = "2023.05.04"
67
+
68
+ parser = CommonArguments()
69
+ parser.singleprofile()
70
+ parser.singleregion()
71
+ parser.verbosity()
72
+ parser.version(__version__)
73
+ parser.my_parser.add_argument(
74
+ "-b",
75
+ "--bucket",
76
+ dest="pBucketName",
77
+ metavar="bucket to empty and delete",
78
+ required=True,
79
+ help="To specify a bucket, use this parameter.",
80
+ )
81
+ parser.my_parser.add_argument(
82
+ "+delete",
83
+ "+force-delete",
84
+ help="Whether or not to delete the bucket after it's been emptied",
85
+ action="store_const",
86
+ dest="pForceQuit",
87
+ const=True,
88
+ default=False,
89
+ )
90
+ args = parser.my_parser.parse_args()
91
+
92
+ pProfile = args.Profile
93
+ pRegion = args.Region
94
+ pBucketDelete = args.pForceQuit
95
+ pBucketName = args.pBucketName
96
+ verbose = args.loglevel
97
+ logging.basicConfig(level=args.loglevel, format="[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s")
98
+
99
+ # Establish AWS session and S3 resource connection
100
+ # Uses the specified profile to access S3 services
101
+ aws_acct = aws_acct_access(pProfile)
102
+ s3 = aws_acct.session.resource(service_name="s3")
103
+
104
+ # CRITICAL WARNING: Display destructive operation warning
105
+ # This ensures users understand the irreversible nature of this operation
106
+ print()
107
+ print(f"This script is about to delete all versions of all objects from bucket {pBucketName}")
108
+ print()
109
+
110
+ # Create S3 bucket resource for the specified bucket
111
+ # This provides access to bucket operations and object management
112
+ bucket = s3.Bucket(pBucketName)
113
+
114
+ try:
115
+ # DESTRUCTIVE OPERATION: Delete all object versions and delete markers
116
+ # This includes:
117
+ # - All current object versions
118
+ # - All historical object versions (if versioning enabled)
119
+ # - All delete markers
120
+ # - Cannot be undone once executed
121
+ logging.info(f"Starting deletion of all object versions in bucket {pBucketName}")
122
+ bucket.object_versions.delete()
123
+ logging.info(f"Successfully deleted all object versions from bucket {pBucketName}")
124
+
125
+ except Exception as my_Error:
126
+ # Handle S3 API errors during object deletion
127
+ # Common errors: AccessDenied, NoSuchBucket, InvalidBucketState
128
+ logging.error(f"Failed to delete objects from bucket {pBucketName}: {my_Error}")
129
+ print(f"Error message: {my_Error}")
130
+
131
+ # Handle bucket deletion with safety controls
132
+ # Provides both automated and interactive deletion modes
133
+ DeleteBucket = False
134
+
135
+ if pBucketDelete:
136
+ # Force deletion mode: Delete bucket without additional confirmation
137
+ # Used for automated scenarios where confirmation is handled externally
138
+ print(f"As per your request, we're deleting the bucket {pBucketName}")
139
+ logging.warning(f"Force deleting bucket {pBucketName} as requested")
140
+
141
+ try:
142
+ bucket.delete()
143
+ print(f"Bucket: {pBucketName} has been deleted")
144
+ logging.info(f"Successfully deleted bucket {pBucketName}")
145
+ except Exception as delete_error:
146
+ logging.error(f"Failed to delete bucket {pBucketName}: {delete_error}")
147
+ print(f"Failed to delete bucket: {delete_error}")
148
+
149
+ else:
150
+ # Interactive deletion mode: Prompt user for confirmation
151
+ # Provides additional safety control for manual operations
152
+ DeleteBucket = input("Now that the bucket is empty, do you want to delete the bucket? (y/n): ") in ["y", "Y"]
153
+
154
+ if DeleteBucket:
155
+ try:
156
+ bucket.delete()
157
+ print(f"Bucket: {pBucketName} has been deleted")
158
+ logging.info(f"User confirmed deletion of bucket {pBucketName}")
159
+ except Exception as delete_error:
160
+ logging.error(f"Failed to delete bucket {pBucketName}: {delete_error}")
161
+ print(f"Failed to delete bucket: {delete_error}")
162
+ else:
163
+ print(f"Bucket: {pBucketName} has NOT been deleted")
164
+ logging.info(f"User chose to preserve bucket {pBucketName}")
165
+ # Operation completion notification
166
+ print()
167
+ print("Thanks for using this script...")
168
+ logging.info("S3 bucket operation completed successfully")
169
+ print()
@@ -0,0 +1,81 @@
1
+ # Using these Inventory Scripts as Discovery
2
+
3
+ ## AWS Cloud Foundations boto3-Aligned Scripts
4
+
5
+ All scripts have been updated to follow boto3 API naming conventions for better AWS professional compatibility.
6
+
7
+ The following script runs for all accounts within either your specified profile, or (if no profile is used) your default credentials (could be environment variables). This will assess whether ALL of your accounts are suitable to be migrated to Control Tower or not, and if not - what the issues preventing their adoption would be. The "-r global" specifies that ALL regions (even those you have not opted into) should be looked at. The script will (because of the "-v") inform you of the failure to connect to an account in the excluded region, but won't fail because of it. This script executes 10 commands for every account in every region, so it will take a **long** time to run.
8
+
9
+ ```sh
10
+ controltower_check_account_readiness.py -v -r global --timing [-p <profile of Org Account>]
11
+ ```
12
+
13
+ This script will go through your Org and find all members accounts and their statuses - thereby showing you which accounts should - perhaps - be moved to a "SUSPENDED" OU or otherwise treated specially. It's useful because the output is very purposeful and it's pretty fast.
14
+
15
+ ```sh
16
+ org_list_accounts.py -v
17
+ ```
18
+
19
+ This next script will find the status of all of your accounts and regions and whether you have CloudTrail enabled in each.
20
+
21
+ ```sh
22
+ cloudtrail_describe_trails_compliance.py -v -r global --timing --filename cloudtrail_check.out [-p <profile of Org Account>]
23
+ ```
24
+
25
+ The following script can draw out the Organization. The output will be a file in the current directory called "aws_organization.png" - please either get that file, or a screenshot of it. Assuming the user has the graphviz tool installed within their environment, running this tool should end with the diagram itself being shown. The parameter "--policy" can also be mitigated by "--aws" to include those policies which AWS owns (like the AWSFullAccess policy assigned by default to every OU and account). The default (below) excludes that AWS-managed policy for diagram clarity's sake.
26
+
27
+ ```sh
28
+ org_describe_structure.py --policy --timing
29
+ ```
30
+
31
+ The following script can do soooo much _(Yeah - I'm pretty proud of this one)_. As it's shown here, it doesn't yet support the "--filename" parameter, since I haven't decided how to write out the data. The goal of using this output in Discovery, is to find those accounts which have been closed (and may no longer be in the Org at all), but are still represented in the stacksets of the Org - and therefore may (eventually) cause stacksets to slow down or fail. Best to find these issues ahead of time, rather than after the fact. For instance - I found a customer with 450 accounts in their Org, but their largest stackset had over 100 closed (and already dropped out) accounts, so while the stackset was still considered "CURRENT", more than 20% of the time spent on that stackset was spent attempting to connect to previously closed accounts.
32
+ ```sh
33
+ cfn_update_stack_sets.py -v -r <home region> --timing [-p <profile of Org Account>] -check
34
+ ```
35
+
36
+ The following script shows whether the "Public S3 block" has been enabled on all accounts within the Org. While Control Tower has a control that can enable this on new accounts, it doesn't mean that it hasn't been removed somewhere. It's a good idea to run this, and you can use the same script to re-enable the block if it's been removed.
37
+
38
+ ```sh
39
+ s3_put_public_access_block.py -v
40
+ ```
41
+
42
+ The following script finds any and all config recorders and delivery channels in your environment - again, this is a tool that is used when trying to determine what blockers exist before moving to Control Tower. It's also a good tool (if you don't need the full complement of checks in the controltower_check_account_readiness.py above) to find any accounts where Config isn't running at all. This tool also can be used to **delete** the config recorders and delivery channels - if needed.
43
+
44
+ ```sh
45
+ config_describe_configuration_recorders.py -v -r global --timing
46
+ ```
47
+
48
+ These scripts will find those IAM/ IDC users, local directories, or SAML providers in your child accounts which can be exposures to unwanted access, without you realizing it. It's always a good idea to look for these - since these can represent a significant threat vector to protect from.
49
+
50
+ ```sh
51
+ org_list_account_users.py -v
52
+ iam_list_saml_providers.py -v
53
+ ds_describe_directories.py -v
54
+ ```
55
+
56
+ While it's normal for this script to find nothing, it's very illuminating if it *does* find something...
57
+
58
+ ```sh
59
+ cfn_find_orphaned_stacks.py --filename Drift_Detection -v
60
+ ```
61
+
62
+ The following scripts will just show very useful Inventory information that will help the Discovery process flesh out its understanding of the customer's environment.
63
+
64
+ ```sh
65
+ ec2_describe_vpcs.py -v
66
+ route53_list_hosted_zones.py -v
67
+ ```
68
+
69
+ Whenever we do Discovery, we always want to find possible money-savings areas for the customer as well. The script below will find any Log Groups and their retention settings. This gives the customer the opportunity (perhaps) to update those retention settings (from their default of "NEVER") to something that will purge data after a specific time. The bottom of the script gives an *idea* of how much you're spending on Log Groups anyway, so you have an idea if taking action is worthwhile.
70
+
71
+ ```sh
72
+ logs_put_retention_policy.py -v
73
+ ```
74
+
75
+ ALZ used Service Catalog to create and manage accounts. It's important that these Service Catalog products are properly terminated when ALZ is decommissioned, so this tool will report on the accounts in the Org reconciled with the Service Catalog Products that were created and point out if there are products for already closed accounts, or whether there are more than one product for a given account (or no products for a given account).
76
+
77
+ > **Note:** Control Tower use Service Catalog as well. Please ensure you do not terminate Control Tower provisioned products.
78
+
79
+ ```sh
80
+ servicecatalog_list_provisioned_products.py -v --timing
81
+ ```