Skip to content

Instantly share code, notes, and snippets.

@rowanu
Created October 12, 2024 04:13
Show Gist options
  • Save rowanu/86f8b455bb5088abcd1e62b36fedc11a to your computer and use it in GitHub Desktop.
Save rowanu/86f8b455bb5088abcd1e62b36fedc11a to your computer and use it in GitHub Desktop.
Get all AWS IAM actions
import requests
import json
def fetch_json(url):
response = requests.get(url)
return response.json()
def main():
# Fetch the main JSON file
main_url = "https://servicereference.us-east-1.amazonaws.com/"
services = fetch_json(main_url)
# Create a dictionary to store all service actions
actions = {}
# Process each service
for service in services:
service_url = service["url"]
service_name = service["service"]
print(f"Fetching data for {service_name}...")
try:
service_data = fetch_json(service_url)
# Extract action names
service_actions = [
action["Name"] for action in service_data.get("Actions", [])
]
# Add to actions dictionary
actions[service_name] = service_actions
print(f"Added {len(service_actions)} actions for {service_name}")
except Exception as e:
print(f"Error processing {service_name}: {str(e)}")
# Save the combined actions to a file
with open("actions.json", "w") as f:
json.dump(actions, f, indent=2)
print("All service actions have been combined into actions.json")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment