Skip to content

Instantly share code, notes, and snippets.

@theipster
Created January 28, 2024 23:14
Show Gist options
  • Save theipster/5e370f7b0671585bda491f423fd6e719 to your computer and use it in GitHub Desktop.
Save theipster/5e370f7b0671585bda491f423fd6e719 to your computer and use it in GitHub Desktop.
Tool for validating whether a Terraform plan is a pure refactor (i.e. zero changes)
#!/bin/sh
# Given a terraform plan at plan.json...
is_refactor=$(jq --exit-status -null-input '[inputs | .resource_changes[].change.actions[] | test("^(read|no-op)$")] | all' plan.json)
# If it's a refactor, do something - e.g. auto-approve a pull request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment