Skip to content

This ruby CLI tool helps you organise large terraform state files into smaller ones by moving chosen resources from a provided state file into another destination state file.

License

Notifications You must be signed in to change notification settings

shebang-labs/terraform-state-split

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform State Split

Terraform State Split is a Ruby-based CLI tool designed to help you organize and manage large Terraform state files. It leverages the tty-prompt gem to provide an interactive command-line interface for moving selected resources between Terraform state files.

Demo

asciicast

Getting Started

From Source

For utilizing this tool, ensure Ruby is installed on your machine. Also, tty-prompt gem along with other required dependencies must be installed using the following command:

bundle install

Terraform must also be installed and initialized within your working directory.

To execute terraform-state-split, use the following commands:

terraform state pull > tf.state # Extract the state file from your Terraform workspace or remote state storage
ruby resource_mover.rb # Run the script and follow the prompts to select the resources to be moved

Homebrew (For MacOS)

For MacOS users, the tool can be installed via Homebrew using the following commands:

brew tap shebang-labs/tap
brew install terraform-state-split

To run terraform-state-split, execute the following:

terraform state pull > tf.state # Extract the state file from your Terraform workspace or remote state storage
terraform-state-split # Run the script and follow the prompts to select the resources to be moved

How to Use

The tool will prompt you to provide the absolute input state file path and the absolute output state file path. These are the paths of the state files from which and to which you wish to move resources.

Next, all resources present in the input state file will be displayed and you'll be prompted to select the ones to be moved. Make your selection using arrow keys, space bar, and enter key.

The tool will then utilize the terraform state mv command to transfer the selected resources from the input state file to the output state file.

About

This ruby CLI tool helps you organise large terraform state files into smaller ones by moving chosen resources from a provided state file into another destination state file.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •