Skip to main content

c7n policy generation script and related utilities

Project description

manheim-c7n-tools

ReadTheDocs.org build status

TravisCI build badge

Docker Hub Build Status

PyPI Version badge

Manheim's Cloud Custodian (c7n) wrapper package, policy generator, runner, and supporting tools.

This project provides common tooling, distributed as a Docker image, for managing Manheim's cloud-custodian (c7n) tooling, including c7n itself, c7n_mailer, and our custom components. This project/repository is intended to be used (generally via the generated Docker image) alongside a configuration repository of a specific layout, containing configuration for one or more AWS accounts.

For documentation on the upstream cloud-custodian project, please see https://cloudcustodian.io/docs/index.html and the source code at https://github.com/cloud-custodian/cloud-custodian.

Introduction and Goals

Cloud Custodian (a.k.a. c7n) is a flexible rules engine for reporting on and enforcing policy in AWS. Manheim has migrated from Netflix Janitor Monkey to Cloud Custodian for our tag enforcement, resource cleanup, cost reduction, and other policy needs. This project provides common tooling to allow us to deploy and manage c7n across multiple AWS accounts.

We're currently deploying all Cloud Custodian policies via AWS Lambda. The default is to run policies once per day, but other execution triggers are available including arbitrary timer triggers as well as CloudTrail, AWS Config and CloudWatch Events.

A description of the initial tooling that turned into this project can be found in this blog post.

.. _index.main_components:

Main Components

The following commands are available in the Docker container (or Python installation), generated as Python package entrypoints:

  • manheim-c7n-runner - A single entrypoint to wrap running one or more, or all, of the following steps (as well as custodian itself, c7n-mailer deploy, and Sphinx documentation build) in the proper order, in either run (real) or dryrun mode.
  • policygen - The python script to generate the actual custodian YML config files from a configuration repo/directory, as well as handling layering of mailer template files. Must be run from a config repository directory.
  • s3-archiver - Script to clean up custodian S3 buckets by moving logs from any deleted policies to an "archived-logs/" prefix.
  • dryrun-diff - Script to compare the number of resources matched per-policy, per-region between a dryrun and the last actual run of each policy, and write the results to a Markdown file (to be added as a comment on the PR). Optionally, a HTML report listing the affected resources in the dryrun can be generated when a jinja template is provided in the ./reporting-template directory.
  • errorscan - Script using boto3 to examine CloudWatch Metrics, Logs, and SQS Dead Letter Queue for cloud-custodian Lambda functions, and alert on any failed executions, dead letters, etc.
  • c7n's built-in mugc Lambda garbage collection. This is vendored-in to manheim-c7n-tools, as c7n provides it only as a non-executable Python source file in their git repo.
  • c7n's c7n-mailer installed as a dependency for convenience.

Installation and Usage

See Installation and Usage

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manheim-c7n-tools-1.3.1.tar.gz (67.5 kB view details)

Uploaded Source

Built Distribution

manheim_c7n_tools-1.3.1-py2.py3-none-any.whl (76.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file manheim-c7n-tools-1.3.1.tar.gz.

File metadata

  • Download URL: manheim-c7n-tools-1.3.1.tar.gz
  • Upload date:
  • Size: 67.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1

File hashes

Hashes for manheim-c7n-tools-1.3.1.tar.gz
Algorithm Hash digest
SHA256 fdb30fc026520fbc91cc6adfedadbd6718f4cf4519f77930db03f9b2cd9d3a42
MD5 1834844837f11993cdce00d9198b1649
BLAKE2b-256 8b66018750e863a3901876acda291c245ca0623e61cb399ac63dc561f3f7a334

See more details on using hashes here.

File details

Details for the file manheim_c7n_tools-1.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: manheim_c7n_tools-1.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 76.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1

File hashes

Hashes for manheim_c7n_tools-1.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f703043adc78626ad02cc55cac25606b3aa0678c8ebfdbef325dd3be5e34c391
MD5 ba0173a7f60004fd0f42a4928a536f9b
BLAKE2b-256 4c5519b44aedef4a5a5d3088fc2cf4873e6b706e7550f8340daa4b77e1e03bd2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page