← 全部工具

suzuki-shunsuke/tfrstate

热度 65 更新于 数据与数据库

Find directories where changed terraform_remote_state data source is used

githubauto-collected

安装

暂未验证可直接使用的安装命令,请查看项目官方文档或 Release。

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 comment

To post comments, github-comment is useful.

  • Create pull requests after running terraform apply