Skip to content

About

Terraform/OpenTofu provider for running shell commands.

Topics

Resources

Code of conduct

Contributing

Stars

7 stars

Watchers

1 watching

Forks

Repository files navigation

Terraform Provider Shell

Terraform GitHub Release (latest SemVer) Release Validate

This Terraform provider runs configured shell commands as part of a Terraform configuration. It provides a script resource and data source for integrating with systems that do not have a native provider. The provider is published on the Terraform Registry.

Quick start

Declare the provider and a version constraint in your Terraform configuration:

terraform {
  required_providers {
    shell = {
      source  = "terr4m/shell"
      version = "~> 1.0"
    }
  }
}

provider "shell" {}

data "shell_script" "example" {
  inputs = {
    greeting = "hello"
  }

  os_commands = {
    default = {
      read = {
        command = <<-EOF
          printf '{"greeting":"%s"}' "$(jq --raw-output '.greeting' <<<"$${TF_SCRIPT_INPUTS}")" > "$${TF_SCRIPT_OUTPUT}"
        EOF
      }
    }
  }
}

Run terraform init to install the provider. This example uses the default Bash interpreter and requires jq on the machine running Terraform. See the Registry docs for provider configuration and the complete data source and resource references.

Warning

This provider executes arbitrary configured commands on the machine running Terraform. Use only trusted scripts and configurations. Commands may run during planning, apply, refresh, and destroy. Inputs and outputs may be persisted in Terraform state; do not pass secrets through them unless you understand the state and logging exposure.

Contributing

Contributions are welcome, including documentation, issues, and code. See CONTRIBUTING for development setup, tests, generation, and linting instructions.

About

Terraform/OpenTofu provider for running shell commands.

Topics

Resources

Code of conduct

Contributing

Stars

7 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages