Install & Compatibility
Where this runs
tested against v0.9.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.498s · 89.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 6.0s · import 1.480s · 91MB
87MB installed
● package 87MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
scan_account_authorization_details
✓ from cloudsplaining.command.scan import scan_account_authorization_details
This quickstart demonstrates how to programmatically scan AWS IAM authorization details using Cloudsplaining. It assumes an `account_authorization_details.json` file, which is typically generated by running `cloudsplaining download` via the CLI. The example creates a dummy JSON file for demonstration purposes. It then uses the `scan_account_authorization_details` function to generate an HTML report string.
import os
import json
from cloudsplaining.command.scan import scan_account_authorization_details
from cloudsplaining.shared.exclusions import DEFAULT_EXCLUSIONS, Exclusions
# NOTE: For a real scan, you would first generate an account authorization details JSON file.
# This typically requires AWS credentials configured (e.g., via AWS CLI or environment variables)
# and the `iam:GetAccountAuthorizationDetails` permission.
# Example CLI command: `cloudsplaining download --output-file account_authorization_details.json`
# For this example, we'll use a dummy file path and content.
dummy_auth_details_path = "account_authorization_details.json"
# In a real scenario, this would be a large JSON file downloaded from AWS.
# Example: https://github.com/salesforce/cloudsplaining/blob/master/examples/files/iam-results-example.json
dummy_auth_details_content = {
"UserDetailList": [],
"GroupDetailList": [],
"RoleDetailList": [
{
"Path": "/",
"RoleName": "TestRoleWithFullS3",
"RoleId": "AROAJEXAMPLEAAAEK",
"Arn": "arn:aws:iam::123456789012:role/TestRoleWithFullS3",
"CreateDate": "2023-01-01T00:00:00Z",
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {"Service": "ec2.amazonaws.com"},
"Action": "sts:AssumeRole"
}
]
},
"AttachedManagedPolicies": [
{
"PolicyName": "AmazonS3FullAccess",
"PolicyArn": "arn:aws:iam::aws:policy/AmazonS3FullAccess"
}
],
"InstanceProfileList": []
}
],
"ManagedPolicyDetailList": [],
"ContextKeyDetailList": []
}
with open(dummy_auth_details_path, "w") as f:
json.dump(dummy_auth_details_content, f)
# Create an empty exclusions object for this quickstart (you might load from a file)
# An exclusions file is recommended for production use to filter out false positives.
exclusions = Exclusions(DEFAULT_EXCLUSIONS)
# Scan the account authorization details file programmatically
try:
print(f"Scanning {dummy_auth_details_path}...")
html_report_string = scan_account_authorization_details(
input_file=dummy_auth_details_path,
exclusions=exclusions,
flag_all_risky_actions=False, # Set to True to flag all risky actions regardless of resource constraints
# You can also set other parameters like 'high_priority_only' or 'severity'
)
# The HTML report content is returned as a string.
# In a real application, you might save this to a file or serve it.
# For this example, we'll just print a snippet.
print("Scan complete. HTML report (snippet):\n")
print(html_report_string[:500] + "...")
# Clean up dummy file
os.remove(dummy_auth_details_path)
except Exception as e:
print(f"An error occurred during scan: {e}")
if os.path.exists(dummy_auth_details_path):
os.remove(dummy_auth_details_path)
cloudsplaining --version
Errors
Common errors & fixes
command not found: cloudsplaining
The `cloudsplaining` executable is not in your system's PATH environment variable, often occurring when installed via `pip3 install --user cloudsplaining` which places executables in a user-specific binary directory not always included in PATH by default.
fixAdd the Python user base binary directory to your PATH. On macOS/Linux, this is typically `~/.local/bin`. For example, add `export PATH="$HOME/.local/bin:$PATH"` to your shell's configuration file (e.g., `~/.bashrc`, `~/.zshrc`) and then restart your terminal or `source` the file.
ModuleNotFoundError: No module named 'policy_sentry.analysis.expand'
This error indicates that a dependency required by cloudsplaining, specifically `policy_sentry`, is either not installed, an incorrect version, or not accessible in your Python environment. This specific issue was a known bug in older versions of Cloudsplaining that has since been fixed.
fixUpgrade cloudsplaining to the latest version by running `pip3 install --upgrade cloudsplaining`. If the issue persists, ensure `policy_sentry` is also up-to-date or installed: `pip3 install --upgrade policy_sentry`.
An error occurred (AccessDeniedException) when calling the GetAccountAuthorizationDetails operation: User: arn:aws:iam::123456789012:user/YourUser is not authorized to perform: iam:GetAccountAuthorizationDetails on resource: arn:aws:iam::123456789012:user/YourUser
The AWS credentials configured for running cloudsplaining lack the necessary IAM permissions (`iam:GetAccountAuthorizationDetails`) to retrieve the account's IAM authorization details, which is a prerequisite for scanning.
fixEnsure the IAM user or role configured in your AWS credentials (e.g., via `~/.aws/credentials` or environment variables) has the `iam:GetAccountAuthorizationDetails` permission. For cross-account scanning, the scanning user also needs `sts:AssumeRole` permissions for the target roles.
Upgrade
Version history
0.9.1latest on PyPI · released Jun 14, 2026
Audit
Dependencies
policy_sentryoptionalCloudsplaining is an assessment tool, while Policy Sentry is a preventative tool for policy authoring and automation. They are complementary, and Policy Sentry is often recommended for remediating issues discovered by Cloudsplaining.