Skip to content

Instantly share code, notes, and snippets.

@pkolyvas
Forked from mildwonkey/installer.md
Created May 15, 2020 20:40
Show Gist options
  • Save pkolyvas/1a49a402f152156060877077289950a2 to your computer and use it in GitHub Desktop.
Save pkolyvas/1a49a402f152156060877077289950a2 to your computer and use it in GitHub Desktop.
Provider Installer overview

Provider Installation

Overview

Terraform 0.13 has an entirely new provider installer that allows for greater control over individual provider installation methods. The breaking change is a new, required, subdirectory hierarchy for provider binaries.

Terraform v0.12

Terraform v0.12 Provider Installer

The key differences between Terraform v0.12 and v0.13 are the directory hierarchy. Terraform v0.12 would look for a provider binary under the following directories:

Search

  1. Filesystem
  2. Terraform Registry

Filesystem search paths

  • Windows: %APPDATA%\terraform.d\plugins
  • All others: ~/.terraform.d/plugins
  • Location of the terraform binary (/usr/local/bin, for example)
  • terraform.d/plugins/<OS>_<ARCH> For airgapped installations; see terraform-bundle

Registry lookup

Terraform queries the Registry for providers:

  • if a compatible provider is not found locally
  • unless the -upgrade flag is set

Configuration Options

  • -plugin-dir: disables registry lookup; only search that directory (note: still searches .terraform/plugins for already-installed providers)
  • plugin-cache-dir: search and install providers to the configured directory. Terraform will search other locations, including the registry, as usual.
  • -upgrade: query the registry for all providers required by the local configuration and install the latest matching version.

Installation

Default:

  • .terraform/plugins

Options:

  • -plugin-cache-dir: does not change search paths; installs providers into the specified directory

Terraform v0.13

New Directory layout

A major implication of the provider source work is that terraform can no longer assume that provider types are unique: a user could have multiple provides with the same type in a given configuration. To support this, terraform now requires the all provider binaries are in a specific directory hierarchy corresponding with the source:

$BASEDIR/$SOURCEHOST/$NAMESPACE/$TYPE/$VERSION/$OS_$ARCH/

Search

  1. Filesystem
  2. Terraform Registry

Filesystem search paths

Default:

  • .terraform.d/plugins relative to the CLI configuration directory (configurable, defaults to $HOME/)
  • terraform.d/plugins in the current working directory (documented in terraform-bundle as a place to put plugins as a way to include them in bundles uploaded to Terraform Cloud)
  • .terraform/plugins relative to configuration for any already-installed plugins

OS-specific paths:

  • Windows: %APPDATA%/HashiCorp/Terraform/plugins
  • Mac OS X: ~/Library/Application Support/io.terraform/plugins and /Library/Application Support/io.terraform/plugins
  • Linux and other Unix-like systems: Terraform implements the XDG Base Directory specification and appends terraform/plugins to all of the specified data directories. Without any XDG environment variables set, Terraform will use ~/.local/share/terraform/plugins, /usr/local/share/terraform/plugins, and /usr/share/terraform/plugins.

Configuration Options

  • -plugin-dir command-line flag: only that directory will be searched (no registry lookup). Command-line options override CLI configuration file options.
  • plugin-cache-dir: search and install providers to the configured directory. Terraform will search other locations, including the registry, as usual.
  • -upgrade: query the registry for all providers required by the local configuration and install the latest matching version.

Registry lookup

Same use-facing behavior as 0.12: terraform queries the registry to find providers. If a provider is found in one of the search paths, terraform will not query the registry for that provider (unless the -upgrade command line flag is used).

CLI configuration settings

We've added a CLI configuration setting, provider_installtion, to let users declare plugin search locations for all configurations on a given workstation. This setting overrides the default behavior.

  • filesystem_mirror: used to declare custom local filesystems
  • direct: used to configure the registry provider search behavior
  • network_mirror: used to declare custom network filesystems [targeting future 0.13.* release]

Installation

Default: .terraform/plugins/$SOURCEHOST/$NAMESPACE/$TYPE/$VERSION/$OS_$ARCH/

Options:

  • -plugin-cache-dir command-line flag: does not change search behavior, just install: plugins will be downloaded into, and installed from, the cache dir
  • plugin_cache_dir CLI config setting: same as above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment