Coder Social home page Coder Social logo

tf-parliament's Introduction

Terraform Parliament - Run Parliament AWS IAM Checker on Terraform Files

Parliament checks IAM policy validity against the latest AWS IAM specifications, so e.g. It'll pick up if your policy uses an older Action like billing:*, instead of the current aws-portal:*

By default, Parliament runs only on JSON IAM policies, not Terraform files. However I wanted to validate my Terraform files.

This utility parses your Terraform, finds aws_iam_policy_document elements, generates resulting IAM policy document strings, and runs Parliament on them.

It stubs any Terraform interpolations ${...} so they can be evaluated by Parliament as valid JSON.

Example run

Issues

  • Sometimes the interpolation stubbing (e.g. "Replace all ${...} in a Resource with *") results in invalid values; needs to be more sophisticated than current regex replace
  • No unit tests :(
  • Currently not fit to be used as a GitHub action (as was my plan) since --recursive not yet implemented

Usage

Docker

DockerHub Repo

Use /github/workspace/ to mount the directory containing the Terraform, since this image is intended to run as a GitHub action:

Intention Command
Run on the entire directory docker run --rm -ti -v (pwd):/github/workspace/ rdkls/tf-parliament
Run on one file docker run --rm -ti -v (pwd):/github/workspace/ rdkls/tf-parliament iam.tf
Run on some TF files only docker run --rm -ti -v (pwd):/github/workspace/ rdkls/tf-parliament 'iam-*.tf'

Notes

  • These examples use fish shell (pwd), in bash switch that to `pwd`
  • Quotes around the argument in the last example, to avoid your shell expanding the wildcard before passing to docker.

Native

pip install -r requirements.txt

tf-parliament.py my-template.tf

(also supports wildcards & directories per Docker method)

Requirements

  • Docker
  • Terraform Files v0.12+ (though v0.11 should work too)

tf-parliament's People

Contributors

rdkls avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.