shell-resource

Invicton-Labs/shell-resource/external

Terraform Module HCL EXTERNAL

A module for running shell commands and capturing their outputs as resources.

Install
module "shell-resource" {
source = "Invicton-Labs/shell-resource/external"
version = "0.4.1"
}
plain text: /constructs/tfmod-invicton-labs-shell-resource-external/install.txt
⭐ Source on GitHub 📦 Registry page
README

Terraform Shell (Resource) On the Terraform Registry: Invicton-Labs/shell-resource/external This module allows generic shell commands to be run as a resource (will only re-run when an input variable changes). It supports both Linux and Windows (Mac currently untested, but should be supported) and requires no external dependencies. This is a complete rewrite of the original module from Matti Paksula; it offers many new features and fixes one of the major issues with the old module, which was that the outputs would not be updated on a trigger change. This module is a workaround for https://github.com/hashicorp/terraform/issues/610, please give it a 👍 so we don't need this module anymore. For Windows, this module should work on any system that supports a relatively modern version of PowerShel

Inputs (21)
NameTypeDescriptionDefault
working_dirstringThe working directory where command will be executed. Defaults to this module's null
fail_create_on_timeoutboolWhether a Terraform error should be thrown if the create command times out (onlytrue
command_unixstringThe command to run on creation when the module is used on a Unix machine. If notnull
environment_sensitivemap(string)Map of (sentitive) environment variables to pass to the command. This map will b{}
environment_triggerlessmap(string)Map of environment variables to pass to the command, which will NOT trigger a re{}
command_destroy_windowsstringThe command to run on destruction when the module is used on a Windows machine. null
fail_create_on_stderrboolWhether a Terraform error should be thrown if the create command outputs anythinfalse
fail_destroy_on_stderrboolWhether a Terraform error should be thrown if the destroy command outputs anythifalse
timeout_destroynumberThe maximum number of seconds to allow the shell command to execute for on resounull
unix_interpreterstringThe interpreter to use when running commands on a Unix-based system. This is pri"/bin/sh"
dynamic_depends_onanyThis input variable has the same function as the `depends_on` built-in variable,null
command_windowsstringThe command to run on creation when the module is used on a Windows machine. If null
command_destroy_unixstringThe command to run on destruction when the module is used on a Unix machine. If null
fail_destroy_on_timeoutboolWhether a Terraform error should be thrown if the destroy command times out (onltrue
timeout_createnumberThe maximum number of seconds to allow the shell command to execute for on resounull
execution_idstringA unique ID for the shell execution. Used for development only and will default null
fail_destroy_on_nonzero_exit_codeboolWhether a Terraform error should be thrown if the destroy command exits with a ntrue
suppress_consoleboolWhether to suppress the Terraform console output (including plan content and shefalse
triggersanyA value (of any type) that, when changed, will cause the script to be re-run (wi{}
environmentmap(string)Map of environment variables to pass to the command. This map will be merged wit{}
Outputs (25)
suppress_console — The value of the `suppress_console` input variable, or the default value if the input was `null`.
fail_create_on_stderr — The value of the `fail_create_on_stderr` input variable, or the default value if the input was `null
fail_destroy_on_nonzero_exit_code — The value of the `fail_destroy_on_nonzero_exit_code` input variable, or the default value if the inp
fail_destroy_on_stderr — The value of the `fail_destroy_on_stderr` input variable, or the default value if the input was `nul
unix_interpreter — The value of the `unix_interpreter` input variable, or the default value if the input was `null`.
null_command_unix — A command that does nothing on Unix-based systems. You can use this output as the value for the `com
command_unix — The value of the `command_unix` input variable, or the default value if the input was `null`, with a
environment — The value of the `environment` input variable, or the default value if the input was `null`, with al
triggers — The value of the `triggers` input variable, or the default value if the input was `null`.
fail_create_on_timeout — The value of the `fail_create_on_timeout` input variable, or the default value if the input was `nul
fail_destroy_on_timeout — The value of the `fail_destroy_on_timeout` input variable, or the default value if the input was `nu
timeout_destroy — The value of the `timeout_destroy` input variable, or the default value if the input was `null`.
id — A unique ID for this resource. The ID does not change when the shell command is re-run.
exit_code — The exit status code of the shell command. If the `timeout` input variable was provided and the comm
command_windows — The value of the `command_windows` input variable, or the default value if the input was `null`, wit
command_destroy_unix — The value of the `command_destroy_unix` input variable, or the default value if the input was `null`
environment_triggerless — The value of the `environment_triggerless` input variable, or the default value if the input was `nu
null_command_windows — A command that does nothing on Windows systems. You can use this output as the value for the `comman
fail_create_on_nonzero_exit_code — The value of the `fail_create_on_nonzero_exit_code` input variable, or the default value if the inpu
timeout_create — The value of the `timeout_create` input variable, or the default value if the input was `null`.
stdout — The stdout output of the shell command, with all carriage returns and trailing newlines removed.
stderr — The stderr output of the shell command, with all carriage returns and trailing newlines removed.
command_destroy_windows — The value of the `command_destroy_windows` input variable, or the default value if the input was `nu
environment_sensitive — The value of the `environment_sensitive` input variable, or the default value if the input was `null
working_dir — The value of the `working_dir` input variable.
Resources (3)
null_resourcerandom_idrandom_uuid
Details
FrameworkTerraform Module
LanguageHCL
Version0.4.1
Cloud EXTERNAL
Total downloads811.0k
Inputs21
Outputs25
Resources3
NamespaceInvicton-Labs
Updated