Skip to main content

Cloud Custodian Provider for evaluating Terraform

Project description

Cloud Custodian Terraform Provider

Custodian's terraform provider enables writing and evaluating custodian policies against Terraform IaaC modules.

tldr: we want to enable writing custodian policies against IaaC assets (terraform, cfn, etc) directly in devops/ci pipelines.

Purpose

The primary purpose of this is to integrate with ci/cd pipelines to evaluate compliance and governance early in the deployment lifecycle. Custodian cloud providers provide for realtime detection and remediation as a detective control against infrastructure already deployed in the environment regardless of how it was provisioned. As an initial target, the terraform provider is designed to complement that with preventive enforcement earlier in the lifecycle. ie. enabling a shift-left to policy enforcement.

Pipeline CLI

In looking at expanding out to shift-left pipeline use cases, one thing that becomes clearer is that custodian's default cli ux isn't perhaps the best fit for the target audience. When we're operating against cloud resources we have to deal with cardinalities in the thousands to millions. When we're operating in the pipelines we're typically dealing with resource cardinalities in the 10s. Additionally there is a goal expectation of having rich output that correlates to the ci tooling (github annotations, etc) or pinpointing the issue for a developer, as well as color'd output and other niceties. we could incorporate that as a new subcommand into the main custodian cli (dependent on presence of iaac providers installed), or have a dedicated subcommand associated.

The other main deficiency with the cli is that we're not able to pass directly the iaac files as data sets we want to consider. Typically policies have expressed this as query parameterization within the policy as being able to specify the exact target set. But the use case here is more typically command line driven with specification of both policy files and target IaaC files, as well as other possible vcs integrations (policystream style wrt delta files) or ci integrations.

Resources

wrt to the iaac provider we can either operate loosely typed or strongly typed. with strong typing we can spec out exact attributes and potentially do additional possibly validation wrt to user specified attributes, but it requires keeping an up to date store of all iaac provider assets, which could be both fairly large and rapidly changing (terraform has over 150 providers all release independently). for now, I think it would be good to keep to loose typing on resources. .. and perhaps document provider addressable resource attributes as part of documentation.

Loose typing would enable working out of the box with extant providers, but policy authors would have to consult reference docs for their respective providers on available attributes or even provider resource type existence. From a custodian perspective we would use a common resource implementation across provider resource types.

Examples

- resource: terraform.aws_dynamodb_table
   name: ensure encryption
   filters:
      server_side_encryption.enabled: true
      kms_key_arn: key_alias

custodian run terraform.yml

custodian report --format=

dedicated cli

custodian run-source terraform.yml

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

c7n_terraform-0.1.22-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file c7n_terraform-0.1.22-py3-none-any.whl.

File metadata

  • Download URL: c7n_terraform-0.1.22-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.17 tqdm/4.66.1 importlib-metadata/5.2.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.1

File hashes

Hashes for c7n_terraform-0.1.22-py3-none-any.whl
Algorithm Hash digest
SHA256 67f32e0ccd3c00939b621072a5d8ef3b40850ff41a46e03d4021790841b287b5
MD5 c988a1feb0e8f559fdf66278f686b510
BLAKE2b-256 4d4170dd0c5b99a8fb0d75851ecc9c2cc3fccda7534d8d13a3c54df8d445b521

See more details on using hashes here.

Supported by

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