Security & FinOps · Freelance

Cloud Governance as Code with Cloud Custodian

A library of policies that auto-tag resources, enforce bucket encryption, remove open security-group rules and report IAM users without MFA, with an SQS-based mailer.

  • Cloud Custodian
  • c7n-mailer
  • CloudTrail
  • Lambda
  • SQS
  • IAM
  • S3
  • Python

// Overview

Policies run in CloudTrail mode so Lambdas fire on API events: auto-tagging instances with their creator, enabling default encryption on new buckets, removing open ingress rules and notifying the user who added them, and finding users with MFA inactive. A mailer delivers notifications through SQS. Multi-account and multi-region variants and report-style policies are included.

// The problem

Compliance needed continuous, automated enforcement of tagging, encryption, network exposure and MFA rules.

// Flow

Cloud Governance as Code with Cloud Custodian flow1. Policy YAML → 2. CloudTrail mode → 3. Filter → 4. Action → 5. Notify → 6. Multi-account → 7. Reporting01Policy YAML02CloudTrail mode03Filter04 · GATEAction05Notify06Multi-account07Reporting
  1. Policy YAMLresource, mode, filters and actions per rule
  2. CloudTrail modeLambda and event rule provisioned for key API events
  3. Filtertag absent, encryption off, open ingress, MFA inactive
  4. Action gateauto-tag, set encryption or remove the rule
  5. Notifymailer emails the offending user via SQS
  6. Multi-accountaccount lists and all-region variants
  7. Reportingreport policies and a control mapping

// Design decisions & guardrails

  • Remediation at event time rather than periodic scans.
  • Notification is attributed to the actor who made the change.
  • Account identifiers are templated, not hardcoded.

// Outcome

Policy violations fixed within seconds of the API call that caused them.

// Related