This script will parse a terraform plan output and generate the commands needed to manipulate a state file. This is useful during migrations. The primary use case this solves for is splitting a terraform state into 2 without having to destroy the terraform resources and recreate.
- Run a plan on the workspace in terraform cloud and download the raw plan by pressing
View raw log
- Copy the plan and rename to the workspace name to avoid confusion. Ex: starting-plan-log.txt
- Run
python main.py destroyed starting-plan-log.txt
to output the terraform state removal commands - Run the state removal commands against the workspace
- Run another plan on the workspace in terraform cloud and validate for no
destroys
in the plan
Download console output by clicking "View as plain text", right click and save as the webpage to a file.
python main.py destroyed plan-log.txt
python main.py created plan-log.txt
python -m unittest tests/test_main.py