terraform-provider-ssh

command module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 4 Imported by: 0

README

ssh Terraform provider

Overview

This is a Terraform provider to copy files, run commands remotely and capture results via SSH. Unlike the Terraform provisioners which are described as a "last resort" this provider embraces the concept of pushing and executing content to compute instances over SSH. Apart from bastion hosts it also supports tunneling over HTTP proxies. This is very useful if you are running Terraform from inside a corporate network and need to reach out to your instances.

Using the provider

Terraform 0.14+: To install this provider, copy and paste this code into your Terraform configuration. Then, run terraform init.

terraform {
  required_providers {
    ssh = {
      source = "loafoe/ssh"
    }
  }
}

Example

resource "ssh_resource" "example" {
  host         = "remote-server.test"
  bastion_host = "jumpgate.remote-host.com"
  user         = "alpine"
  agent        = true

  file {
    content     = "echo '{\"hello\":\"world\"}' && exit 0"
    destination = "/home/alpine/test.sh"
    permissions = "0700"
  }

  timeout = "3m"

  commands = [
    "/home/alpine/test.sh",
  ]
}

output "result" {
  value = try(jsondecode(ssh_resource.example.result), {})
}

The above example snippet uploads a generated shell script, executes it remotely and captures the output for further use in Terraform.

Development requirements

  • Terraform 0.15.0 or newer
  • Go 1.17 or newer (to build the provider plugin)

Issues

LICENSE

License is MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL