webhook2lambda2sqs.terraform_runner module

class webhook2lambda2sqs.terraform_runner.TerraformRunner(config, tf_path)[source]

Bases: object

_args_for_remote()[source]

Generate arguments for ‘terraform remote config’. Return None if not present in configuration.

Returns:list of args for ‘terraform remote config’ or None
Return type:list
_get_outputs()[source]

Return a dict of the terraform outputs.

Returns:dict of terraform outputs
Return type:dict
_run_tf(cmd, cmd_args=[], stream=False)[source]

Run a single terraform command via run_cmd(); raise exception on non-zero exit status.

Parameters:
  • cmd (str) – terraform command to run
  • cmd_args (list) – arguments to command
Returns:

command output

Return type:

str

Raises:

Exception on non-zero exit

_set_remote(stream=False)[source]

Call _args_for_remote(); if the return value is not None, execute ‘terraform remote config’ with those arguments and ensure it exits 0.

Parameters:stream (bool) – whether or not to stream TF output in realtime
_setup_tf(stream=False)[source]

Setup terraform; either ‘remote config’ or ‘init’ depending on version.

_show_outputs()[source]

Print the terraform outputs.

_taint_deployment(stream=False)[source]

Run ‘terraform taint aws_api_gateway_deployment.depl’ to taint the deployment resource. This is a workaround for https://github.com/hashicorp/terraform/issues/6613

Parameters:stream (bool) – whether or not to stream TF output in realtime
_validate()[source]

Confirm that we can run terraform (by calling its version action) and then validate the configuration.

apply(stream=False)[source]

Run a ‘terraform apply’

Parameters:stream (bool) – whether or not to stream TF output in realtime
destroy(stream=False)[source]

Run a ‘terraform destroy’

Parameters:stream (bool) – whether or not to stream TF output in realtime
plan(stream=False)[source]

Run a ‘terraform plan’

Parameters:stream (bool) – whether or not to stream TF output in realtime