-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
local-app/python-tools/cross-organization/tag-checker/generate-aws-service-map.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/bin/env python | ||
|
|
||
| import requests | ||
| import json | ||
| import re | ||
|
|
||
| __version__ = "1.0.0" | ||
|
|
||
| def fetch_aws_service_data(): | ||
| """ | ||
| Fetches the list of service prefixes and friendly names from | ||
| AWS Policy Sentry's maintained data (official-ish source of truth). | ||
| """ | ||
| print("[*] Fetching latest AWS service metadata...") | ||
| # This URL points to a well-maintained community list derived from IAM docs | ||
| url = "https://raw.githubusercontent.com/salesforce/policy_sentry/master/policy_sentry/shared/data/iam-definition.json" | ||
|
|
||
| try: | ||
| response = requests.get(url, timeout=10) | ||
| response.raise_for_status() | ||
| data = response.json() | ||
|
|
||
| service_map = {} | ||
| for service in data: | ||
| prefix = service.get('prefix') | ||
| name = service.get('service_name') | ||
| if prefix and name: | ||
| service_map[prefix] = name | ||
|
|
||
| return service_map | ||
| except Exception as e: | ||
| print(f"[!] Failed to fetch data: {e}") | ||
| return None | ||
|
|
||
| def main(): | ||
| service_map = fetch_aws_service_data() | ||
| if service_map: | ||
| output_file = "aws_service_map.json" | ||
| with open(output_file, 'w') as f: | ||
| json.dump(service_map, f, indent=4) | ||
| print(f"[+] Successfully generated {output_file} with {len(service_map)} services.") | ||
| else: | ||
| print("[!] Could not generate map.") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |