tfrstate (Terraform Remote State)
MIT | Install | Usage
CLI to find directories where changed terraformremotestate data source is used.
You can warn changes of Terraform Output Values in CI:
You can also create pull requests via CI to reflect changes of Output Values to Terraform Root Modules:
Overview
When Terraform Output Values are updated, you would want to reflect the update to Terraform Root Modules where referring those values via terraformremotestate data sources. Or when you remove Terraform Output Values, you would want to know which Terraform Root Modules are depending on those values.
tfrstate is a CLI to find Terraform Root Modules depending on a given Terraform State via terraformremotestate. Using this tool, you can look into the dependency, notifying to people when changing output values in CI, and creating pull requests to reflect changes of output values after applying changes.
Supported Backends
- S3 Backend
- GCS Backend
How To Use
Please see PoC too.
- Check directories where a specific output is used.
tfrstate find -s3-bucket mybucket -s3-key path/to/my/key -output foo- Post a comment when outputs are changed in CI
terraform plan -out plan.out
terraform show -json plan.out > plan.json
tfrstate find -plan-json plan.json -base-dir "$(git rev-parse --show-toplevel)" > result.json
length=$(jq length result.json)
if [ "$length" -eq 0 ]; then
exit 0
fi
# Post a commentTo post comments, github-comment is useful.
- Create pull requests after running terraform apply