All Projects → matti → Terraform Shell Resource

matti / Terraform Shell Resource

Licence: mit
Run (exec) a command in shell and capture the output (stdout, stderr) and status code (exit status)

Labels

Projects that are alternatives of or similar to Terraform Shell Resource

Terraform Aws Cloudfront S3 Cdn
Terraform module to easily provision CloudFront CDN backed by an S3 origin
Stars: ✭ 162 (-10.5%)
Mutual labels:  hcl
Getting Started Terraform
Stars: ✭ 171 (-5.52%)
Mutual labels:  hcl
Stack
A set of Terraform modules for configuring production infrastructure with AWS
Stars: ✭ 2,080 (+1049.17%)
Mutual labels:  hcl
Terraform Aws Openshift
Create infrastructure with Terraform and AWS, install OpenShift. Party!
Stars: ✭ 165 (-8.84%)
Mutual labels:  hcl
Terraform Aws Cloudtrail Cloudwatch Alarms
Terraform module for creating alarms for tracking important changes and occurrences from cloudtrail.
Stars: ✭ 170 (-6.08%)
Mutual labels:  hcl
Tfk8s
A tool for converting Kubernetes YAML manifests to Terraform HCL
Stars: ✭ 167 (-7.73%)
Mutual labels:  hcl
Dcos Kubernetes Quickstart
Quickstart guide for Kubernetes on DC/OS
Stars: ✭ 161 (-11.05%)
Mutual labels:  hcl
Tf aws bastion s3 keys
A Terraform module for creating bastion host on AWS EC2 and populate its ~/.ssh/authorized_keys with public keys from bucket
Stars: ✭ 178 (-1.66%)
Mutual labels:  hcl
Terraform Aws Components
Opinionated, self-contained Terraform root modules that each solve one, specific problem
Stars: ✭ 168 (-7.18%)
Mutual labels:  hcl
K8s Scw Baremetal
Kubernetes installer for Scaleway bare-metal AMD64 and ARMv7
Stars: ✭ 176 (-2.76%)
Mutual labels:  hcl
Terraform Aws Autoscaling
Terraform module which creates Auto Scaling resources on AWS
Stars: ✭ 166 (-8.29%)
Mutual labels:  hcl
C1m
Nomad, Terraform, and Packer configurations for the Million Container Challenge (C1M)
Stars: ✭ 167 (-7.73%)
Mutual labels:  hcl
Heroku
GitHub Action for interacting with Heroku
Stars: ✭ 172 (-4.97%)
Mutual labels:  hcl
Terraform Aws Rds Aurora
Terraform module which creates RDS Aurora resources on AWS
Stars: ✭ 165 (-8.84%)
Mutual labels:  hcl
Terraform Gke Kubeflow Cluster
Terraform module for creating GKE clusters to run Kubeflow
Stars: ✭ 177 (-2.21%)
Mutual labels:  hcl
Terraform Kubernetes Installer
Terraform Installer for Kubernetes on Oracle Cloud Infrastructure
Stars: ✭ 162 (-10.5%)
Mutual labels:  hcl
Terraform Amazon Ecs
Terraform files for deploying and running Amazon ECS (+ Private Docker Registry)
Stars: ✭ 171 (-5.52%)
Mutual labels:  hcl
Hcl Picker
🎨 Colorpicker for data
Stars: ✭ 178 (-1.66%)
Mutual labels:  hcl
Nomad Guides
Example usage of HashiCorp Nomad
Stars: ✭ 178 (-1.66%)
Mutual labels:  hcl
Terraform Aws Foundation
Establish a solid Foundation on AWS with these modules for Terraform
Stars: ✭ 173 (-4.42%)
Mutual labels:  hcl

terraform-shell-resource

Build Status

A workaround for https://github.com/hashicorp/terraform/issues/610 <-- please 👍, meanwhile:

This module runs a command as a null_resource and makes the stdout, stderr and exit status available as outputs (stored in triggers map). See an external data source version with more features at https://github.com/matti/terraform-shell-outputs (that runs on every apply, this one only runs once when the resource is created and if command is changed).

Usage

module "files" {
  source  = "matti/resource/shell"
  command = "ls -l"
}

output "my_files" {
  value = module.files.stdout
}
...
Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

Outputs:

my_files = total 16
-rw-r--r--  1 mpa  staff   112 Feb  9 09:06 main.tf
-rw-r--r--  1 mpa  staff  1007 Feb  9 09:07 terraform.tfstate

Full usage

module "first" {
  source = "matti/resource/shell"

  command = ">/tmp/first echo I was here first"
}

module "greeting" {
  source = "matti/resource/shell"

  # workaround for missing depends_on in modules
  depends = [
    module.first.id
  ]

  environment = {
    GREETING = "hello"
  }

  command              = "echo $GREETING world from $(pwd) where /tmp/first has content: $(cat /tmp/first)"
  command_when_destroy = "echo $GREETING and good bye from $(pwd)"

  # runs on every apply
  trigger = timestamp()

  working_dir = "/tmp"
}

output "greeting" {
  value = module.greeting.stdout
}
Apply complete! Resources: 6 added, 0 changed, 0 destroyed.

Outputs:

greeting = hello world from /private/tmp where /tmp/first has content: I was here first

Additional examples

See tests and examples

Related issues:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].