Skip to content

Instantly share code, notes, and snippets.

@dynnamitt
Last active May 15, 2025 11:51
Show Gist options
  • Save dynnamitt/71e956efe101763f290091d5dd650a10 to your computer and use it in GitHub Desktop.
Save dynnamitt/71e956efe101763f290091d5dd650a10 to your computer and use it in GitHub Desktop.
#!/usr/bin/make -f
# needs jq, terraform, git
SHA = $(shell git rev-parse --short HEAD)
TF_WRKSPC = $(shell terraform workspace show)
SUFF = $(SHA)-$(TF_WRKSPC)
.PHONY: summary
summary: /tmp/delete_$(SUFF).json /tmp/update_$(SUFF).json /tmp/create_$(SUFF).json
@echo " -------- DELETE -----------"
jq -r '.address' $(word 1,$^)
@echo " -------- UPDATE -----------"
jq -r '.address' $(word 2,$^)
@echo " -------- CREATE -----------"
jq -r '.address' $(word 3,$^)
/tmp/%_$(SUFF).json: /tmp/plan_$(SUFF).json
jq -r '.resource_changes[] | select(.change.actions[0]=="$*")' <$< >$@
/tmp/plan_$(SUFF).json: /tmp/plan_$(SUFF)
terraform show -no-color -json $< >$@
/tmp/plan_$(SUFF):
terraform plan -out=$@
clean:
rm /tmp/plan_$(SUFF)
@dynnamitt
Copy link
Author

make -f deeper-plan.mk
Use jless to execute "deepPlanning" on the separate files.
Usecase: Advanced tf-state move ops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment