Class: RubyTerraform::Commands::ProvidersMirror

Inherits:
Base
  • Object
show all
Includes:
Options::Global
Defined in:
lib/ruby_terraform/commands/providers_mirror.rb

Overview

Wraps the terraform providers mirror command which saves local copies of all required provider plugins.

Populates a local directory with copies of the provider plugins needed for the current configuration, so that the directory can be used either directly as a filesystem mirror or as the basis for a network mirror and thus obtain those providers without access to their origin registries in future.

The mirror directory will contain JSON index files that can be published along with the mirrored packages on a static HTTP file server to produce a network mirror. Those index files will be ignored if the directory is used instead as a local filesystem mirror.

For options accepted on construction, see Base#initialize.

When executing an instance of ProvidersMirror via Base#execute, the following options are supported:

  • :directory: the directory to populate with the mirrored provider plugins.

  • :chdir: the path of a working directory to switch to before executing the given subcommand.

  • :platform: the target platform to build a mirror for; by default Terraform will obtain plugin packages suitable for the platform where you run this command; target names consist of an operating system and a CPU architecture; for example, “linux_amd64” selects the Linux operating system running on an AMD64 or x86_64 CPU; each provider is available only for a limited set of target platforms; if both :platform and :platforms are provided, all platforms will be passed to Terraform.

  • :platforms: an array of target platforms to build a mirror for for; see :platform for more details; if both :platform and :platforms are provided, all platforms will be passed to Terraform.

The Base#execute method accepts an optional second parameter which is a map of invocation options. Currently, the only supported option is :environment which is a map of environment variables to expose during invocation of the command.

Examples:

Basic Invocation

RubyTerraform::Commands::ProvidersMirror.new.execute(
  directory: './plugins',
  platforms: ["windows_amd64", "darwin_amd64", "linux_amd64"])

Method Summary

Methods inherited from Base

#execute, #initialize

Constructor Details

This class inherits a constructor from RubyTerraform::Commands::Base