No description
Find a file
2016-11-25 10:46:12 +08:00
python_terraform python-terraform-1 Make option with bool value/ more sense for the caller 2016-11-24 15:09:16 +08:00
test python-terraform-1 Make option with bool value/ more sense for the caller 2016-11-24 16:18:30 +08:00
.bumpversion.cfg Bump version: 0.7.7 → 0.7.8 2016-11-25 10:46:12 +08:00
.gitignore python-terraform-1 Make option with bool value/ more sense for the caller 2016-11-24 15:13:43 +08:00
.travis.yml python-terraform-1 Make option with bool value/ more sense for the caller 2016-11-24 15:20:35 +08:00
DESCRIPTION.rst change description 2016-11-20 01:11:21 +08:00
LICENSE.txt 1. update travis deploy 2016-11-19 18:24:33 +08:00
MANIFEST.in release 0.0.2 to fury 2016-02-25 17:38:05 +08:00
README.md python-terraform-1 Make option with bool value/ more sense for the caller 2016-11-24 15:09:16 +08:00
release.py add release script 2016-02-25 17:22:37 +08:00
requirements.txt python-terraform-1 Make option with bool value/ more sense for the caller 2016-11-24 15:13:43 +08:00
setup.cfg 1. add test cases, try tdd 2016-11-18 15:35:14 +08:00
setup.py fix description 2016-11-20 01:44:35 +08:00
tox.ini python-terraform-1 Make option with bool value/ more sense for the caller 2016-11-24 15:20:35 +08:00
VERSION Bump version: 0.7.7 → 0.7.8 2016-11-25 10:46:12 +08:00

Introduction

python-terraform is a python module provide a wrapper of terraform command line tool. terraform is a tool made by Hashicorp, please refer to https://terraform.io/

Status

Build Status

Installation

pip install python-terraform

Usage

For any terraform command

def cmd(self, cmd, *args, **kwargs):
    """
    run a terraform command, if success, will try to read state file
    :param cmd: command and sub-command of terraform, seperated with space
                refer to https://www.terraform.io/docs/commands/index.html
    :param args: arguments of a command
    :param kwargs:  any option flag with key value without prefixed dash character
            if there's a dash in the option name, use under line instead of dash,
                ex. -no-color --> no_color
            if it's a simple flag with no value, value should be IsFlagged
                ex. cmd('taint', allow_missing=IsFlagged)
            if it's a boolean value flag, assign True or false
            if it's a flag could be used multiple times, assign list to it's value
            if it's a "var" variable flag, assign dictionary to it
            if a value is None, will skip this option
    :return: ret_code, out, err

Examples

Have a test.tf file under folder "/home/test"

apply with variables a=b, c=d, refresh=False, no color in the output

In shell:

cd /home/test
terraform apply -var='a=b' -var='c=d' -refresh=false -no-color

In python-terraform:

from python_terraform import Terraform
tf = terraform(working_dir='/home/test')
tf.apply(no_color=IsFlagged, refresh=False, var={'a':'b', 'c':'d'})

taint command, allow-missing and no color

In shell:

cd /home/test
terraform taint -allow-missing -no-color

In python-terraform:

from python_terraform import Terraform
tf = terraform(working_dir='/home/test')
tf.cmd('taint', allow_missing=IsFlagged, no_color=IsFlagged)