Files
opentf/website/docs/cli/commands/providers/mirror.mdx
2023-09-15 16:03:23 +02:00

61 lines
2.8 KiB
Plaintext

---
description: |-
The `opentf providers mirror` command downloads the providers required
for the current configuration and copies them into a directory in the local
filesystem.
---
# Command: providers mirror
The `opentf providers mirror` command downloads the providers required
for the current configuration and copies them into a directory in the local
filesystem.
In normal use, `opentf init` will automatically download needed providers
from provider registries as part of initializing the current working directory.
Sometimes OpenTF is running in an environment where that isn't possible,
such as on an isolated network without access to an OpenTF Registry. In
that case,
[explicit installation method configuration](/docs/cli/config/config-file#explicit-installation-method-configuration)
allows you to configure OpenTF, when running on a particular system, to
consult only a local filesystem directory where you've created a local mirror
of the necessary plugins, and to skip accessing the upstream registry at all.
The `opentf providers mirror` command can automatically populate a directory
that will be used as a local filesystem mirror in the provider installation
configuration.
## Usage
Usage: `opentf providers mirror [options] <target-dir>`
A single target directory is required. OpenTF will create under that
directory the path structure that is expected for filesystem-based provider
plugin mirrors, populating it with `.zip` files containing the plugins
themselves.
OpenTF will also generate various `.json` index files which contain suitable
responses to implement
[the network mirror protocol](/docs/internals/provider-network-mirror-protocol),
if you upload the resulting directory to a static website host. OpenTF
ignores those index files when using the directory as a filesystem mirror,
because the directory entries themselves are authoritative in that case.
This command supports the following additional option:
* `-platform=OS_ARCH` - Choose which target platform to build a mirror for.
By default OpenTF will obtain plugin packages suitable for the platform
where you run this command. Use this flag multiple times to include packages
for multiple target systems.
Target platform 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.
You can run `opentf providers mirror` again on an existing mirror directory
to update it with new packages. For example, you can add packages for a new
target platform by re-running the command with the desired new `-platform=...`
option, and it will place the packages for that new platform without removing
packages you previously downloaded, merging the resulting set of packages
together to update the JSON index files.