Deployment orchestration using terraform
Terracanary provides a wrapper for terraform that manages multiple versions of terraform stacks and facilitates sharing data between multiple related stacks. This allows you to easily construct complex deployment procedures.
# Apply database infrastructure updates
terracanary apply --stack database
# Run database migrations
...
# Build new copy of infrastructure, using shared database
NEW_VERSION=$(terracanary next)
terracanary apply --stack-version main:$NEW_VERSION --input-stack database
# Run some automated tests on new main stack
HOSTNAME_TO_TEST=$(terracanary output --stack-version main:$NEW_VERSION hostname)
...
# Start sending traffic to new main stack
terracanary apply --stack routing --input-stack-version main:$NEW_VERSION
# Clean up old stack(s)
terracanary destroy --all main --except main:$NEW_VERSION
For more complete examples see the examples folder.
Terracanary must be run from a working directory which has subdirectories containing the terraform definitions for each stack. Terracanary will create a ".terracanary" config file when you run "terracanary init" to set up the working directory. So for the above example, the layout would look like:
.
|-- database
| \-- *.tf
|
|-- main
| \-- *.tf
|
|-- routing
| \-- *.tf
|
\-- .terracanary
-h, --help help for terracanary
- terracanary apply - Apply changes to a stack
- terracanary args - Set args that will be passed to terraform for plan/apply/destroy
- terracanary destroy - Destroys one or more stacks
- terracanary init - Set args that will be passed to 'terraform init'
- terracanary list - List all stacks
- terracanary next - Output next unused version number (across all stacks)
- terracanary output - Retrieve terraform outputs from specified stack
- terracanary plan - Plan changes to a stack
- terracanary test - Check if there are any changes to a stack
- terracanary util - General utilities to help deployment scripts