A tool to help with some Terraform operations.
For the time being it generates state migration scripts that work also for Terraform workspaces. The idea of migrations comes from the excellent tfmigrate.
This is BETA code, although we already use it in production. The instructions provide also ways to manually recover, but be careful and ensure you UNDERSTAND what you are doing if you use it for something important!
You have been warned.
The API can change in breaking ways until we reach v1.0.0
Collect informations for Terravalet:
$ cd $ROOT_MODULE_DIR
$ terraform plan -no-color 2>&1 | tee plan-01.txt
Take as input the Terraform plan plan-01.txt
and generate UP and DOWN migration scripts:
$ terravalet -plan=plan-01.txt \
-up=../migrations/001_TITLE.up.sh -down=../migrations/001_TITLE.down.sh
NOTE: It us up to the user to ensure that the migration number is correct with respect to what is already present in the migration directory.
- Download the archive for your platform from the releases page.
- Unarchive and copy the
terravalet
executable somewhere in your$PATH
. I like to use$HOME/bin/
.
- Install Go.
- Install task.
- Run
task
$ task
- Copy the executable
bin/terravalet
to a directory in your$PATH
. I like to use$HOME/bin/
.
- Install github-release.
- Install gopass or equivalent.
- Configure a GitHub token:
3.1 Go to Personal Access tokens
3.2 Click on "Generate new token"
3.3 Select only the
repo
scope - Store the token securely with a tool like
gopass
. The nameGITHUB_TOKEN
is expected bygithub-release
$ gopass insert gh/terravalet/GITHUB_TOKEN
- Update CHANGELOG
- Update this README and/or additional documentation.
- Commit and push.
- Begin the release process with
$ env RELEASE_TAG=v0.1.0 gopass env gh/terravalet task release
- Finish the release process by following the instructions printed by
task
above. - To recover from a half-baked release, see the hints in the Taskfile.
This code is released under the MIT license, see file LICENSE.