Code Monkey home page Code Monkey logo

python-drift's Introduction

drifter README

This is a simple python script to detect drift in IAC repos/statefiles.

For each run of the script, drifter will iterate over the list of statefiles listed in the REPO_LIST config file. For each statefile listed, if drift is detected, a slack notification will be sent to the channel configured via the Slack webhook. The notification provides a direct link to the offending statefile.

Screenshot

Configuration and Secrets

Typically this would be run in some sort of cron automation, perhaps as a GitLab or Kubernetes cron job. Regardles of where the job runs, there are a few elements of config to consider, some which are secrets.

SLACK_WEBHOOK_URL

This should be configured in Slack and then injected as an envvar to the process: export SLACK_WEBHOOK_URL=https://hooks.slack.com/services/FAKE_DATA

REPO_LIST

This is the list of repos that the drifter needs to iterate over. drifter can select the repo-list file with the -f flag. Since it is possible for multiple terraform states to be present in a single IAC repo, the format of the repo-list file requires a single line per repo-state combination in the following format:

github.com:geojaz/drifter-test/repo-1

Git Server: github.com Owner/group: geojaz Repo name: drifter-test Repo path/statefile path: repo-1

Important! The actor executing drifter (whether a service account or a human) needs read only access to all of the git repos listed in the repo-list config file.

It also needs read only GCP org access. This code should work the same for AWS or other terraform managed clouds, but will similarly need broad read-only access sufficient to run terraform plan.

The implementation here is left to the user since there are several options that vary depending on use case. In automation for GCP, the recommendation is to use Workload Identity to act as a service account with the correct permissions. Alternatively, export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.

python-drift's People

Contributors

geojaz avatar

Watchers

James Cloos avatar  avatar  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.