Code Monkey home page Code Monkey logo

terraform-state-mover's Introduction

Go Report Card Actions Status codecov License Release

Terraform State Mover

Helps refactoring terraform code by offering an interactive prompt for the terraform state mv command.

Installation

Using homebrew:

brew install mbode/tap/terraform-state-mover

Alternatively, get a pre-built binary from the latest release or build it yourself using

go get github.com/mbode/terraform-state-mover

Usage

terraform-state-mover # inside a Terraform root directory

Extra arguments after a -- are passed to the terraform plan call. This makes the following possible:

terraform-state-mover -- -var key=value  # set variables
terraform-state-mover -- -var-file=variables.tfvars  # use variable files
terraform-state-mover -- -refresh=false  # skip state refresh
terraform-state-mover -- -parallelism=50  # speed up plan by using more concurrent operations

Hint: If terraform-state-mover is used with the Google Cloud Platform provider and remote state, it is recommended to use --delay=2s, otherwise API rate limits error might occur.

Key mapping

Key Action
Select
Next
Previous
Page Down
Page Up

Demo

Terraform version compatibility

< 0.10.1 0.10.1…8 0.11.0…15 0.12.0…31 0.13.0…7 0.14.0…11 0.15.0…5 1.0.0…11 1.1.0…9 1.2.0…2

Contributing

Pull requests are welcome. Please make sure to update tests as appropriate.

License

MIT

Similar tools

  • tfautomv - Generate Terraform moved blocks automatically for painless refactoring

terraform-state-mover's People

Contributors

dbirks avatar dependabot-preview[bot] avatar dependabot[bot] avatar mbode avatar pascal-hofmann avatar xanonid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

terraform-state-mover's Issues

Feature request: Order suggestions based on editing distance

If many resources needed to be moved (e.g. because extracted to a new module) with similar resource types, it would be helpful if the list of suggested target resources are ordered by editing distance between the source/target resource paths such that the top-most/preselected target resource is more probably the correct one.

Rate-limiting terraform state mv calls

For example, with the google terraform provider and remote state, terraform state mv could only be called approximately every 2 seconds, otherwise the state cannot be locked anymore due to rate limits by Google APIs.

If there are more than only few renamings, terraform-state-mover could fail because of this. It would be nice if there is either a default rate limit or a flag which allows to delay the terraform calls.

Terragrunt Support

Hi, I was just wondering if at all, there was a plan or an existing way to read input variables from a gruntwork terragrunt file instead of a tfvars file?

root@c6cacc87b3af:/workdir/environments/poc# terraform-state-mover -- -var-file=terragrunt.hcl

Error: Unexpected "include" block

  on terragrunt.hcl line 1:
   1: include {

Blocks are not allowed here.

exit status 1

Propagate -parallelism=50 tf plan CLI argument to planner.go

To achieve faster plan, I had to modify source code to make 22nd line of planner.go file like the following:

if err := terraformExec(cfg, true, args, "plan", "-out="+tfPlanName, "-parallelism=60"); err != nil {

Would be nice to have this as a built-in feature

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.