shell-resource
Invicton-Labs/shell-resource/external
A module for running shell commands and capturing their outputs as resources.
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
| Name | Type | Description | Default |
|---|---|---|---|
| working_dir | string | The working directory where command will be executed. Defaults to this module's | null |
| fail_create_on_timeout | bool | Whether a Terraform error should be thrown if the create command times out (only | true |
| command_unix | string | The command to run on creation when the module is used on a Unix machine. If not | null |
| environment_sensitive | map(string) | Map of (sentitive) environment variables to pass to the command. This map will b | {} |
| environment_triggerless | map(string) | Map of environment variables to pass to the command, which will NOT trigger a re | {} |
| command_destroy_windows | string | The command to run on destruction when the module is used on a Windows machine. | null |
| fail_create_on_stderr | bool | Whether a Terraform error should be thrown if the create command outputs anythin | false |
| fail_destroy_on_stderr | bool | Whether a Terraform error should be thrown if the destroy command outputs anythi | false |
| timeout_destroy | number | The maximum number of seconds to allow the shell command to execute for on resou | null |
| unix_interpreter | string | The interpreter to use when running commands on a Unix-based system. This is pri | "/bin/sh" |
| dynamic_depends_on | any | This input variable has the same function as the `depends_on` built-in variable, | null |
| command_windows | string | The command to run on creation when the module is used on a Windows machine. If | null |
| command_destroy_unix | string | The command to run on destruction when the module is used on a Unix machine. If | null |
| fail_destroy_on_timeout | bool | Whether a Terraform error should be thrown if the destroy command times out (onl | true |
| timeout_create | number | The maximum number of seconds to allow the shell command to execute for on resou | null |
| execution_id | string | A unique ID for the shell execution. Used for development only and will default | null |
| fail_destroy_on_nonzero_exit_code | bool | Whether a Terraform error should be thrown if the destroy command exits with a n | true |
| suppress_console | bool | Whether to suppress the Terraform console output (including plan content and she | false |
| triggers | any | A value (of any type) that, when changed, will cause the script to be re-run (wi | {} |
| environment | map(string) | Map of environment variables to pass to the command. This map will be merged wit | {} |
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 `nullfail_destroy_on_nonzero_exit_code — The value of the `fail_destroy_on_nonzero_exit_code` input variable, or the default value if the inpfail_destroy_on_stderr — The value of the `fail_destroy_on_stderr` input variable, or the default value if the input was `nulunix_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 `comcommand_unix — The value of the `command_unix` input variable, or the default value if the input was `null`, with aenvironment — The value of the `environment` input variable, or the default value if the input was `null`, with altriggers — 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 `nulfail_destroy_on_timeout — The value of the `fail_destroy_on_timeout` input variable, or the default value if the input was `nutimeout_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 commcommand_windows — The value of the `command_windows` input variable, or the default value if the input was `null`, witcommand_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 `nunull_command_windows — A command that does nothing on Windows systems. You can use this output as the value for the `commanfail_create_on_nonzero_exit_code — The value of the `fail_create_on_nonzero_exit_code` input variable, or the default value if the inputimeout_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 `nuenvironment_sensitive — The value of the `environment_sensitive` input variable, or the default value if the input was `nullworking_dir — The value of the `working_dir` input variable.