Cloud Custodian — Cloud Security & Cost Governance Rules Engine
A YAML-based rules engine for managing cloud resources across AWS, Azure, and GCP. Cloud Custodian enforces security policies, optimizes costs, and ensures compliance through automated actions on non-compliant resources.
Agent 可直接安装
这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。
npx -y tokrepo@latest install 7b0e8ddf-39d2-11f1-9bc6-00163e2b0d79 --target codex先 dry-run 确认安装计划,再运行此命令。
What it is
Cloud Custodian is a CNCF-hosted rules engine that lets teams define cloud governance policies in YAML. Each policy specifies a resource type (EC2 instances, S3 buckets, Azure VMs), filters to match non-compliant resources, and actions to remediate (tag, stop, terminate, encrypt, notify). It supports AWS, Azure, GCP, and Kubernetes.
Cloud Custodian is built for DevOps engineers, security teams, and FinOps practitioners who need automated enforcement of security posture, compliance mandates, and cost optimization rules across multi-cloud environments.
How it saves time or tokens
Without Custodian, teams write ad-hoc scripts per cloud provider to audit resources. Custodian replaces those scripts with a declarative DSL -- one YAML file per policy. The engine handles API pagination, rate limiting, credential management, and retry logic. Policies run as Lambda functions or Cloud Functions for real-time event-driven enforcement, eliminating cron-based audit lag. For AI workflows, the YAML format is concise enough that generating or reviewing policies consumes minimal tokens.
How to use
- Install the CLI:
pip install c7n(addc7n-azureorc7n-gcpfor non-AWS clouds). - Write a policy YAML file defining resource type, filters, and actions.
- Run the policy:
custodian run -s output policy.yml. Results are written to the output directory.
Example
policies:
- name: s3-require-encryption
resource: s3
filters:
- type: bucket-encryption
state: false
actions:
- type: notify
subject: 'Unencrypted S3 bucket found'
to:
- security-team@example.com
transport:
type: sqs
queue: custodian-notifications
This policy scans all S3 buckets, filters those without encryption enabled, and sends a notification via SQS.
Related on TokRepo
- DevOps AI tools -- infrastructure automation and cloud management tools
- Security AI tools -- security scanning and compliance utilities
Common pitfalls
- Running policies with destructive actions (terminate, delete) without first doing a dry run. Always test with
--dryrunbefore applying actions that modify or remove resources. - Forgetting to scope policies by region. By default Custodian runs in your default region only. Use
--region allor specify regions explicitly for global coverage. - Not setting up proper IAM roles for Lambda-mode policies. Custodian needs permissions to both read resources and perform the configured actions.
常见问题
Cloud Custodian supports AWS natively with the core c7n package. Azure support is available via c7n-azure, GCP via c7n-gcp, and Kubernetes via c7n-kube. Each provider has its own set of resource types, filters, and actions.
Yes. Custodian can deploy policies as AWS Lambda functions triggered by CloudTrail events, enabling real-time enforcement. When a non-compliant resource is created, the policy runs immediately rather than waiting for a scheduled scan.
Custodian includes filters for identifying underutilized resources (low CPU, zero connections), unattached volumes, old snapshots, and untagged resources. Actions can stop, resize, or terminate wasteful resources automatically.
Yes. Custodian is used in production by organizations managing thousands of AWS accounts. It supports multi-account execution via c7n-org, which runs policies across an AWS Organization or a list of accounts in parallel.
AWS Config Rules are AWS-native and limited to AWS resources. Cloud Custodian is open-source, multi-cloud, and offers richer filter logic and action types. Custodian policies are portable YAML files rather than Lambda code tied to AWS Config.
引用来源 (3)
- Cloud Custodian GitHub— Cloud Custodian is a CNCF project with 400+ built-in filters
- Cloud Custodian Documentation— Supports AWS, Azure, GCP, and Kubernetes resource management
- Cloud Custodian Lambda Docs— Lambda-mode policies for real-time event-driven enforcement
讨论
相关资产
Prowler — Cloud Security Assessment for AWS, Azure and GCP
Prowler is an open-source security tool that audits your cloud infrastructure against hundreds of compliance checks for AWS, Azure, GCP, and Kubernetes, generating actionable reports.
ScoutSuite — Multi-Cloud Security Auditing Tool
ScoutSuite is an open-source multi-cloud security auditing tool that collects configuration data from AWS, Azure, GCP, and other providers to identify security risks through automated rule-based analysis.
Quickwit — Cloud-Native Sub-Second Search Engine
Quickwit is a cloud-native search engine built in Rust for log management and distributed search on object storage. It indexes data directly to S3-compatible stores, enabling cost-efficient search at petabyte scale.
CloudQuery — Sync Cloud Infrastructure to SQL for Security and Compliance
CloudQuery is an open-source ELT framework that extracts configuration data from cloud APIs, SaaS platforms, and databases into PostgreSQL or data lakes for security, compliance, and asset visibility.