Registry / devops / c7n-terraform

c7n-terraform

JSON →
library0.1.35pypypiunverified

Cloud Custodian provider for evaluating Terraform plan/state files against custodian policies. Version 0.1.35, requires Python 3.9-3.12. Part of Cloud Custodian suite, but released separately on PyPI. This is a community-maintained provider with limited updates.

pip install c7n-terraform
INSTALL
IMPORT
SIG · C7N-TERRAFORM
C
c7n-terraform
devopspythonv0.1.35
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TerraformProvider
from c7n_terraform import TerraformProvider
from c7n_terraform.provider import TerraformProvider

Example: parse a Terraform plan file and run a custodian policy to find S3 buckets without encryption.

from c7n_terraform.provider import TerraformProvider from c7n.policy import Policy, PolicyCollection import json provider = TerraformProvider() # Load a Terraform plan file (JSON output of terraform plan -out=plan.tfplan) with open('plan.json') as f: resources = provider.parse(json.load(f)) # Define a policy to check for unencrypted S3 buckets policy_data = { 'name': 's3-no-encryption', 'resource': 'terraform.aws_s3_bucket', 'filters': [{'type': 'value', 'key': 'server_side_encryption_configuration', 'value': None}], 'actions': [{'type': 'notify', 'to': ['devnull'], 'subject': 'Compliance', 'message': 'Bucket {} has no encryption'}] } policy = Policy(policy_data, {}) results = provider.run([policy], resources) for r in results: print(r['resource']['id'])
Debug
Known issues
gotchac7n-terraform parses Terraform plan files, not live cloud resources. It only evaluates the planned changes in the JSON output from 'terraform show -json plan.tfplan'.
fix
Ensure you generate a plan file with 'terraform plan -out=plan.tfplan' and then convert to JSON with 'terraform show -json plan.tfplan > plan.json'.
affects: all
gotchaThe provider may not support all Terraform resource types. Unsupported resources are silently ignored.
fix
Check the resource type mapping in the c7n-terraform source or test with your Terraform config. Use 'terraform.aws_*' naming convention.
affects: 0.1.x
deprecatedc7n-terraform is not actively maintained as of 2025. Cloud Custodian core may have breaking changes that affect it.
fix
Consider using the built-in 'terraform' provider that was added to c7n core in 0.9.41.0. Import from 'c7n.providers.terraform' if using c7n>=0.9.41.
affects: 0.1.x
Upgrade
Version history
0.1.35latest on PyPI · released Jun 2, 2025
Audit
Dependencies
c7nrequiredCore Cloud Custodian library required for policy execution
jsonschemarequiredUsed for policy validation
Agent activity
48 hits · last 30 days
node
42
OpenAI (training)
1
Resources