Cloud Custodian

0.9.50 · active · verified Fri Apr 10

Cloud Custodian (c7n) is an open-source, cloud-native rules engine for managing public cloud accounts and resources. It enables users to define policies in simple YAML files to ensure well-managed, secure, and cost-optimized cloud infrastructure. It supports major cloud providers like AWS, Azure, and GCP, and can execute policies in real-time (via serverless functions) or periodically (via scheduled jobs). The current version is 0.9.50, and it maintains an active release cadence with frequent updates and feature additions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a simple policy in a YAML file (`policy.yml`) to identify unencrypted S3 buckets in AWS and then execute it using the `custodian` CLI tool. The `--dryrun` flag allows you to preview actions without making actual changes. Ensure your AWS credentials are configured (e.g., via `~/.aws/credentials` or environment variables) for `custodian` to interact with your cloud environment.

# policy.yml
policies:
  - name: find-unencrypted-s3-buckets
    resource: aws.s3
    filters:
      - type: unencrypted
    actions:
      # Remove or comment out 'actions' for a pure dry-run without notification setup
      - type: notify
        violation_messages:
          - "S3 bucket {resource_id} in {account_id} is not encrypted!"
        to:
          - "{{ resource_owner_email | default(owner@example.com) }}"
        transport:
          type: sqs # Requires c7n-mailer and an SQS queue named 'cloud-custodian-notifications'
          queue: cloud-custodian-notifications

# To run the policy (ensure AWS credentials are configured):
custodian run --dryrun -s . policy.yml

view raw JSON →