runway.module.terraform module¶
Terraform module.
-
runway.module.terraform.
gen_workspace_tfvars_files
(environment, region)[source]¶ Generate possible Terraform workspace tfvars filenames.
-
runway.module.terraform.
update_env_vars_with_tf_var_values
(os_env_vars, tf_vars)[source]¶ Return os_env_vars with TF_VAR_ values for each tf_var.
-
class
runway.module.terraform.
Terraform
(context, path, options=None)[source]¶ Bases:
runway.module.RunwayModule
Terraform Runway Module.
Instantiate class.
- Parameters
-
auto_tfvars
¶ Decorator for creating cached properties.
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
-
current_workspace
¶ Decorator for creating cached properties.
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
-
env_file
¶ Decorator for creating cached properties.
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
-
property
skip
¶ Determine if the module should be skipped.
- Returns
To skip, or not to skip, that is the question.
- Return type
-
tfenv
¶ Decorator for creating cached properties.
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
-
tf_bin
¶ Decorator for creating cached properties.
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
-
cleanup_dot_terraform
()[source]¶ Remove .terraform excluding the plugins directly.
This step is crucial for allowing Runway to deploy to multiple regions or deploy environments without promping the user for input.
The plugins directory is retained to improve performance when they are used by subsequent runs.
-
handle_backend
()[source]¶ Handle backend configuration.
This needs to be run before “skip” is assessed or env_file/auto_tfvars is used in case their behavior needs to be altered.
-
handle_parameters
()[source]¶ Handle parameters.
Either updating environment variables or writing to a file.
-
terraform_workspace_list
()[source]¶ Execute
terraform workspace list
command.https://www.terraform.io/docs/commands/workspace/list.html
- Returns
The available Terraform workspaces.
- Return type
-
terraform_workspace_new
(workspace)[source]¶ Execute
terraform workspace new
command.https://www.terraform.io/docs/commands/workspace/new.html
- Parameters
workspace (str) – Terraform workspace to create.
-
terraform_workspace_select
(workspace)[source]¶ Execute
terraform workspace select
command.https://www.terraform.io/docs/commands/workspace/select.html
- Parameters
workspace (str) – Terraform workspace to select.
-
terraform_workspace_show
()[source]¶ Execute
terraform workspace show
command.https://www.terraform.io/docs/commands/workspace/show.html
- Returns
The current Terraform workspace.
- Return type
-
class
runway.module.terraform.
TerraformOptions
(args, backend, workspace, version=None, write_auto_tfvars=False)[source]¶ Bases:
runway.module.ModuleOptions
Module options for Terraform.
Instantiate class.
- Parameters
args (Union[Dict[str, List[str]], List[str]]) – Arguments to append to Terraform CLI commands. If providing a list, all arguments will be passed to
terraform apply
only. Can also be provided as a mapping to pass arguments toterraform apply
,terraform init
, and/orterraform plan
.backend (TerraformBackendConfig) – Backend configuration.
workspace (str) – Name of the Terraform workspace to use. While it is recommended to let Runway manage this automatically, it has been exposed as an option for cases when a static workspace needs to be used (e.g. remote backend).
version (Optional[str]) – Terraform version.
write_auto_tfvars (bool) – Optionally write parameters to a tfvars file instead of updating environment variables.
-
static
resolve_version
(context, terraform_version=None, **_)[source]¶ Resolve terraform_version option.
-
classmethod
parse
(context, path=None, **kwargs)[source]¶ Parse the options definition and return an options object.
- Parameters
context (Context) – Runway context object.
path (Optional[Path]) – Path to the module.
- Keyword Arguments
args (Union[Dict[str, List[str]], List[str]]) – Arguments to append to Terraform CLI commands. If providing a list, all arguments will be passed to
terraform apply
only. Can also be provided as a mapping to pass arguments toterraform apply
,terraform init
, and/orterraform plan
.terraform_backend_config (Optional[Dict[str, str]]) – Mapping of Terraform backend configuration options.
terraform_backend_cfn_outputs (Optional[Dict[str, str]]) – Mapping of Terraform backend configuration options whose values are stored in Cloudformation outputs.
terraform_backend_ssm_params (Optional[Dict[str, str]]) – Mapping of Terraform backend configuration options whose values are stored in SSM parameters.
terraform_version (Optional[Union[Dict[str, str], str]]) – Version of Terraform to use when processing a module.
terraform_workspace (str) – Name of the Terraform workspace to use. While it is recommended to let Runway manage this automatically, it has been exposed as an option for cases when a static workspace may be needed.
terraform_write_auto_tfvars (bool) – Optionally write parameters to a tfvars file instead of updating environment variables.
- Returns
TerraformOptions
-
class
runway.module.terraform.
TerraformBackendConfig
(context, config_file=None, **kwargs)[source]¶ Bases:
runway.module.ModuleOptions
Terraform backend configuration module options.
Instantiate class.
See Terraform documentation for the keyword arguments needed for the desired backend.
https://www.terraform.io/docs/backends/types/index.html
-
OPTIONS
= ['terraform_backend_config', 'terraform_backend_cfn_outputs', 'terraform_backend_ssm_params']
-
init_args
¶ Decorator for creating cached properties.
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
-
static
resolve_cfn_outputs
(client, **kwargs)[source]¶ Resolve CloudFormation output values.
- Parameters
client (CloudformationClient) – Boto3 Cloudformation client.
- Keyword Arguments
- Returns
Resolved values from Cloudformation.
- Return type
-
static
gen_backend_filenames
(environment, region)[source]¶ Generate possible Terraform backend filenames.
-
classmethod
parse
(context, path=None, **kwargs)[source]¶ Parse backend options and return an options object.
- Parameters
context (Context) – Runway context object.
path (Optional[Path]) – Path to the module.
- Keyword Arguments
terraform_backend_config (Optional[Dict[str, str]]) – Mapping of Terraform backend configuration options.
terraform_backend_cfn_outputs (Optional[Dict[str, str]]) – Mapping of Terraform backend configuration options whose values are stored in Cloudformation outputs.
terraform_backend_ssm_params (Optional[Dict[str, str]]) – Mapping of Terraform backend configuration options whose values are stored in SSM parameters.
- Returns
TerraformBackendConfig
-