Skip to main content

Parse Terraform plan in json format and give feedback.

Project description

terraplanfeed

pre-commit badge Conventional commits badge Keep a Changelog v1.1.0 badge MIT License Badge

This tool parses Terraform plan files in JSON format and gives feedback about the changes.

Description

This tool aims to parse Terraform plan files (in JSON format) and gives feedback to several types of outputs.

Outputs can be:

  • stdout: stdout
  • azuredevops: Azure DevOps pull request comment
  • github: Github pull request comment (not yet implemented)

To create the Terraform plan file:

terraform init
terraform plan -out=plan.out
terraform show -no-color -json plan.out > plan.json

Usage

To write to stdout you just need to pass a JSON file:

 terraplanfeed ../tfplan/example.json

Summary of changes:
===================

(): <known after apply> (module.failover_rg.azurerm_resource_group.rg)
(): <known after apply> (module.failover_rg.module.naming.random_string.first_letter)
(): <known after apply> (module.failover_rg.module.naming.random_string.main)
(): <known after apply> (module.rg.azurerm_resource_group.rg)
(): <known after apply> (module.rg.module.naming.random_string.first_letter)
(): <known after apply> (module.rg.module.naming.random_string.main)
(): <known after apply> (module.sql.azurerm_storage_account.audit1)
(): <known after apply> (module.sql.azurerm_storage_account.audit2[0])
(): <known after apply> (module.sql.module.naming.random_string.first_letter)
(): <known after apply> (module.sql.module.naming.random_string.main)
(): <known after apply> (module.sql.module.naming_failover.random_string.first_letter)
(): <known after apply> (module.sql.module.naming_failover.random_string.main)
 terraplanfeed ../tfplan/example.json -o azuredevops

To use this on Azure DevOps you need the following environment variables:

  • SYSTEM_TEAMFOUNDATIONSERVERURI
  • SYSTEM_TEAMPROJECT
  • BUILD_REPOSITORY_ID
  • SYSTEM_PULLREQUEST_PULLREQUESTID
  • SYSTEM_ACCESSTOKEN

these environment variables are present when you run Azure DevOps pipelines.

Note: The SYSTEM_PULLREQUEST_PULLREQUESTID is only present when you run pipeline in a pull request.

If any of these environment variables are not present, output defaults to stdout

Run and test locally

python3 -m pip install --editable .

Build and upload to PyPI

To build and upload to Test PyPI repository:

python3 -m pip install --user --upgrade setuptools wheel
python3 setup.py sdist bdist_wheel
python3 -m pip install --user --upgrade twine
python3 -m twine upload --repository testpypi dist/*

To upload to PyPI repository:

python3 -m twine upload dist/*

pre-commit hooks

Read the pre-commit hooks document for more info.

git-chglog

Read the git-chglog document for more info.

References

Project details


Download files

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

Source Distribution

terraplanfeed-0.9.2.tar.gz (10.8 kB view hashes)

Uploaded Source

Built Distribution

terraplanfeed-0.9.2-py2.py3-none-any.whl (12.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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