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. The control will automatically create the resources defined in the Terraform stack before experiment execution and destroy them once the experiment is completed.
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 in Chaos Toolkit |
| 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 Chaos Toolkit 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 provided 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 |
Provide Input Variables for Terraform
You can override input variables defined in the Terraform module from within the experiment using the variables argument for the control:
controls:
- name: "Deploy Terraform module"
provider:
type: python
module: chaosterraform.control
arguments:
variables:
vpc_id: "vpc-0000000000"
number_of_azs: 2
Alternatively, you can provide input variables from Chaos Toolkit configuration by referencing a parameter name already defined in Chaos Toolkit configuration:
configuration:
env_name: "live"
...
controls:
- name: "Deploy Terraform module"
provider:
type: python
module: chaosterraform.control
arguments:
variables:
environment:
name: "env_name"
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
In addition, we can ask the chaosterraform.control to map Terraform output values to new Chaos Toolkit configuration variables or override existing ones using the outputs argument:
controls:
- name: "Deploy Terraform module"
provider:
type: python
module: chaosterraform.control
arguments:
outputs:
alb_dns_name: "application_dns_name"
In the example above, the control will map the output value alb_dns_name into a new Chaos Toolkit configuration application_dns_name that can be referenced in the experiment template using the ${application_dns_name} notation.
Metadata
Release files for chaostoolkit-terraform 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chaostoolkit-terraform-0.0.9.tar.gz | 19.1 kB | Without provenance | Details for chaostoolkit-terraform-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chaostoolkit_terraform-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for chaostoolkit_terraform-0.0.9-py3-none-any.whl |
Total release size: 37.7 kB
Release files / chaostoolkit-terraform-0.0.9.tar.gz
| Download URL | chaostoolkit-terraform-0.0.9.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e0dc061fb800d480a13227f9b14db7883a7634c5551c4059229a6060492d413
|
|
BLAKE2b-256 checksum How to use checksums |
637eb99f5bd325c0f94df975ea558d273ea4b3e4d16570a954acfc642634baba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / chaostoolkit_terraform-0.0.9-py3-none-any.whl
| Download URL | chaostoolkit_terraform-0.0.9-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d231ff76daae557c85fb3378a786d684f5d0be18133260a96857c1abae12c62
|
|
BLAKE2b-256 checksum How to use checksums |
3751201ca3a85435e094662b43fe803f9c8a9b63eea2b165e3c22c058436505e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for chaostoolkit-terraform 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.