Skip to content

Latest commit

 

History

History
86 lines (70 loc) · 3.04 KB

index.md

File metadata and controls

86 lines (70 loc) · 3.04 KB
page_title subcategory description
dokku Provider
Interact with dokku

dokku Provider

Interact with dokku

Example Usage

terraform {
  required_providers {
    dokku = {
      source = "registry.terraform.io/aliksend/dokku"
    }
  }
}

# simple configuration
provider "dokku" {
  ssh_host = "127.0.0.1"
}

# custom certificate
# raw certificate can be provided
variable "ssh_cert" {
  type        = string
  description = "SSH cert"
  default     = "~/.ssh/id_rsa"
}

provider "dokku" {
  ssh_host     = "127.0.0.1"
  ssh_port     = 2222
  ssh_cert     = var.ssh_cert
  ssh_host_key = "127.0.0.1 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCql...Dq+Nnpue8="
}

Schema

Required

  • ssh_host (String) Host to connect to

Optional

  • log_ssh_commands (Boolean) Print SSH commands with ERROR level

  • ssh_cert (String) Certificate (private key) to use. Default: ~/.ssh/id_rsa

    Supported formats:

    • file:/a or /a or ./a or ~/a - use provided value as path to certificate file
    • env:ABCD or $ABCD - use env var ABCD
    • raw:----... or ----... - use provided value as raw certificate
  • ssh_host_key (String) Host public key to use. By default key from ~/.ssh/known_hosts will be used. To get public keys for your ssh_host, run ssh-keyscan <ssh_host>. Must be set for usage within Terraform Cloud.

  • ssh_port (Number) Port to connect to. Default: 22

  • ssh_skip_host_key_check (Boolean) Skip the host key check. Insecure, should not be used in production. Default: false

  • ssh_user (String) Username to use. Default: dokku

  • upload_app_name (String) This attribute is used to upload local files to remote server using storage.local_directory attribute. App name to use for local file synchronization. Default: storage-sync

    Since dokku don't allow to upload files directly, workaround is used. Algorithm is:

    1. Create helper dokku application, using name provided in this attribute plus random string to prevent conflicts with simultaneous uploads
    2. Mount desired remote directory as /mnt
    3. Deploy "busybox" docker image to app
    4. [on host side] Create tar archive for local_directory and encode it using base64
    5. Connect to app using "dokku enter" and use a bunch of echo-s to make file "tmp.tar.base64"
    6. When file is completely uploaded - decode and un-tar it to /mnt
    7. Delete helper dokku application

    See details in description to "upload_app_name" attribute.

  • upload_split_bytes (Number) This attribute is used to upload local files to remote server using storage.local_directory attribute. Number of bytes to split uploaded base64-encoded tar archive. See details in description to "upload_app_name" attribute. Default: 256

    Due to limited length of commands we can't use one echo to copy entire file. So we need to split file into parts no larger than upload_split_bytes. Don't use big values because if length of command exceed the limit all operation will hang out.