A Chaos Toolkit module to deploy terraform stacks
Project description
chaostoolkit-terraform
A Chaos Toolkit driver to extend chaos experiments with Terraform
Package Installation
From Python package index
To install the latest chaostoolkit-terraform
stable release:
pip install -U chaostoolkit-terraform
Edge version from the GitHub repository
To install the edge version of the chaostoolkit-terraform
package directly from the repository source code:
pip install -U "git+https://github.com/mcastellin/chaostoolkit-terraform.git#egg=chaostoolkit-terraform"
Usage
chaostoolkit-terraform provides a control to deploy terraform modules. To activate the chaosterraform.control
for your experiments
you need to define it in your experiment files (or settings):
title: My experiment
description: ...
controls:
- name: "Deploy Terraform module"
provider:
type: python
module: chaosterraform.control
steady-state-hypothesis: {...}
method: []
By default the chaosterraform.control
will reference the Terraform module found in the current working directory.
The control will execute Terraform command in the following phases of the experiment execution:
Phase | Actions |
---|---|
Configure control | Initialize the Terraform driver |
Before experiment | Initialize and apply the selected Terraform module |
After experiment | Run terraform destroy unless specifically asked to retain the created resources |
Configuration
You can configure the Terraform control either via control arguments or using Chaos Toolkit parameters with the tf_conf__
prefix:
Configuration with control arguments
controls:
- name: "Deploy Terraform module"
provider:
type: python
module: chaosterraform.control
arguments:
silent: false
retain: true
Configuration using Ctk parameters
configuration:
# parameters prefixed with `tf_conf__` will configure chaosterraform driver
tf_conf__silent: false
tf_conf__retain: true
controls:
- name: "Deploy Terraform module"
provider:
type: python
module: chaosterraform.control
When both options are supplied configuration parameters supplied via the experiment configuration will be used.
Parameter Name | Usage |
---|---|
silent | Suppress Terraform console output to avoid verbose experiment logs, defaults to true |
retain | Do not run terraform destroy at the end of the experiment to retain resources, defaults to false |
chdir | Instruct Terraform to change its working directory before running subcommands |
Set Terraform Input Variables
You can override input variables defined in the Terraform module from within the experiment using
Chaos Toolkit configuration parameters prefixed by tf__
:
configuration:
# parameters prefixed with `tf__` will set terraform input variables for the module
tf__vpc_id: "vpc-0000000000"
tf__number_of_azs: 2
...
controls:
- name: "Deploy Terraform module"
provider:
type: python
module: chaosterraform.control
Use Terraform Outputs In Chaos Experiments
If your Terraform module exports some output variables you can use them in the Chaos Toolkit experiments
as regular experiment parameters. Such variables are added to the configuration context with the tf_out__
prefix.
For example, this Terraform module exports a load balancer DNS name:
terraform {
...
}
output "alb_dns_name" {
value = aws_lb.application_lb.dns_name
}
We can use the exported DNS name in our chaos experiment like so:
controls:
- name: "Deploy Terraform module"
provider:
type: python
module: chaosterraform.control
steady-state-hypothesis:
title: "Application is available"
probes:
- type: probe
name: "should-respond-200"
tolerance: 200
provider:
type: http
url: "http://${tf_out__alb_dns_name}"
method: "GET"
timeout: 3
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for chaostoolkit-terraform-0.0.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff63c31f21be81d12d6733ab70716cda852c93fe97e7ffd775efdbdc424f37cf |
|
MD5 | b0ec1142c30ba089dbe1b194808ef5f6 |
|
BLAKE2b-256 | e5400c2d218ee6c40fc645c3b98c1fbea7da46fb19e87687b0e0070a0daeefda |
Hashes for chaostoolkit_terraform-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7534a26657aa118f2139abae6cb0e1fdde5b83e4f02dc93202f65833af6cc950 |
|
MD5 | 583d14e36045b0b9fc6813f6ee42d701 |
|
BLAKE2b-256 | 8b86ba9edab3a33182b97494f3e6223823e651572680abc1ca757b447173e7d6 |