Registry / devops / c7n-org

c7n-org

JSON →
library0.6.49pypypiunverified

c7n-org is a command-line tool designed to execute Cloud Custodian policies across multiple cloud accounts (AWS, Azure, GCP, OCI) in parallel. It centralizes policy definition and enforcement for large cloud environments, simplifying governance and compliance at scale. The current version is 0.6.49, and it is regularly updated in conjunction with the main Cloud Custodian project.

pip install c7n-org
INSTALL
IMPORT
SIG · C7N-ORG
C
c7n-org
devopspythonv0.6.49
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

c7n-org operates via the command line, requiring an `accounts.yml` file that defines the target cloud accounts and regions, and Custodian policy files (e.g., `policy.yml`). This example demonstrates setting up these files and shows the command to run `c7n-org` to execute policies across multiple accounts and regions. For AWS, the `accounts.yml` can be dynamically generated using `c7n-org aws-accounts -f accounts.yml` if AWS Organizations is configured.

import os # Create a dummy accounts.yml for demonstration accounts_yaml_content = ''' accounts: - account_id: '123456789012' name: dev-account regions: - us-east-1 - us-west-2 role: arn:aws:iam::123456789012:role/CloudCustodian - account_id: '987654321098' name: prod-account regions: - us-east-1 role: arn:aws:iam::987654321098:role/CloudCustodian ''' # Create a simple Custodian policy to find untagged S3 buckets policy_yaml_content = ''' policies: - name: untagged-s3-buckets resource: aws.s3 filters: - "tag:Project": absent actions: - type: notify subject: Untagged S3 Bucket Found to: - email@example.com # Replace with a valid email for actual use transport: type: sqs queue: https://sqs.us-east-1.amazonaws.com/123456789012/my-notification-queue ''' # Write content to files with open('accounts.yml', 'w') as f: f.write(accounts_yaml_content) with open('policy.yml', 'w') as f: f.write(policy_yaml_content) # Simulate running c7n-org via subprocess for demonstration # In a real scenario, you would run this command in your shell print("Simulating c7n-org execution...") print("Command: c7n-org run -c accounts.yml -s output -p policy.yml") print("\n--- Output Directory Structure ---") print("output/") print("├── dev-account/") print("│ ├── us-east-1/") print("│ │ └── untagged-s3-buckets/") print("│ └── us-west-2/") print("│ └── untagged-s3-buckets/") print("└── prod-account/") print(" └── us-east-1/") print(" └── untagged-s3-buckets/") print("----------------------------------") # Cleanup dummy files os.remove('accounts.yml') os.remove('policy.yml')
c7n-org --version
Debug
Known issues
breakingPython 3.9.2 is the minimum required version, and support is limited to Python 3.x (less than 4.0.0). Older Python versions are not supported.
fix
Ensure your environment uses Python >=3.9.2 and <4.0.0. Upgrade Python if necessary.
affects: <0.6.0 (for older Python 3.8 and below)
gotchaExecuting policies across multiple accounts requires properly configured cross-account IAM roles (e.g., `OrganizationAccountAccessRole` for AWS) in each target account that `c7n-org` will assume. Without correct permissions, policies will fail silently or with access denied errors.
fix
Verify that the IAM role specified in `accounts.yml` exists in each target account and grants sufficient permissions for `c7n-org` to assume it and execute policies.
affects: All versions
gotchaThe `c7n-org report` command currently only supports generating reports from locally stored output directories. It cannot directly process output stored in cloud object storage (e.g., S3).
fix
Before generating a report, ensure that the policy execution output is synced or copied to a local directory accessible to the `c7n-org report` command.
affects: All versions
gotchaLogging from `c7n-org` can sometimes be too concise, hiding specific cloud provider error messages and making troubleshooting complex issues, especially permission-related ones, difficult.
fix
Increase logging verbosity where possible (e.g., `-v` flag if available), and consult underlying cloud provider logs (CloudTrail, CloudWatch Logs) for more detailed error information. Consider raising an issue for improved logging if specific gaps are identified.
affects: All versions
gotchaThere have been reports of `c7n-org` encountering errors when targeting AWS accounts in non-default regions, potentially related to regional STS endpoints.
fix
Ensure the AWS CLI and Boto3 configurations properly handle regional STS endpoints. If issues persist, consider explicit region configurations in `accounts.yml` or check for updates to `c7n-org`.
affects: Potentially all versions, but reported in versions around 0.6.0-0.6.x.
Errors
Common errors & fixes
NoCredentialsError: Unable to locate credentials
c7n-org cannot find valid AWS credentials to authenticate with AWS services, often due to missing or incorrectly configured AWS CLI profiles, environment variables, or IAM roles.
fix
Ensure your AWS credentials are configured correctly, for example, by setting the AWS_PROFILE environment variable, configuring `~/.aws/credentials` and `~/.aws/config`, or ensuring the IAM role specified in `accounts.yml` has the necessary permissions and can be assumed by c7n-org. You might need to use `export AWS_PROFILE=your_profile_name` or define the `role` in your `accounts.yml`.
ValueError: max_workers must be <= X
This error occurs on Windows systems when the number of `max_workers` configured for parallel execution exceeds the operating system's limit for process creation, typically related to Python's `concurrent.futures.process` module.
fix
Reduce the `max_workers` value in your c7n-org command (e.g., `--max-workers N`) or configuration file to a number less than or equal to the indicated limit (X), often around 61 on Windows. The default is usually sufficient.
TypeError: __init__() missing 1 required positional argument: 'manager'
This typically indicates an incompatibility between your installed `c7n-org` version and its underlying `c7n` (Cloud Custodian) dependency, or other related Python packages, often due to outdated versions or conflicting installations.
fix
Upgrade both `c7n` and `c7n-org` to their latest compatible versions using `pip install --upgrade c7n c7n-org`. If the issue persists, consider creating a clean Python virtual environment and reinstalling the libraries.
An error occurred (AccessDeniedException) when calling the CreateFunction operation: Cross-account pass role is not allowed.
c7n-org is attempting to deploy a policy (e.g., creating a Lambda function) into a target account, but the IAM role used by c7n-org in the managing account lacks the necessary `sts:AssumeRole` permission for the target account's role, or the target account's role's trust policy does not allow the managing account's role to assume it.
fix
Verify that the IAM role specified in your `c7n-org` configuration (the role that `c7n-org` assumes in the target accounts) has a trust policy allowing the managing account's principal (user or role) to assume it. Also, ensure the managing account's execution role has `sts:AssumeRole` permissions for the target account's role.
Upgrade
Version history
0.6.49latest on PyPI · released Mar 18, 2026
Audit
Dependencies
c7nrequiredc7n-org acts as a runner for Cloud Custodian policies; Cloud Custodian (c7n) must also be installed.
Agent activity
52 hits · last 30 days
node
44
OpenAI (training)
1
Resources
c7n-org — pip install c7n-org · libregistry