Generate a human readable diff of Terraform Plan changes, using Unified format (unidiff
)
npx @ahmadnassri/terraform-unidiff /path/to/plan.json
npm install @ahmadnassri/terraform-unidiff
const unidiff = require('@ahmadnassri/terraform-unidiff')
const plan = fs.readFileSync('path/to/plan.json')
const { summary, patches } = unidiff(plan)
console.log(patches) // array of changes in unidiff format
console.log(summary) // object with changes counts { create: 1, update: 3, delete: 0 }
to obtain a Terraform plan in JSON format, run the following command:
terraform plan -out terraform.plan && terraform show -json terraform.plan > terraform.json
Author: Ahmad Nassri • Twitter: @AhmadNassri