Terraform Provider Manager

July 20, 2023

terraformlogo

The Terraform Provider Manager (tpm) is a powerful command-line interface (CLI) tool designed to streamline the management of Terraform providers in the plugin cache directory. With tpm, users can effortlessly install, uninstall, and list providers, all without the need for the complete Terraform binary on their systems. This innovative tool simplifies provider version management and ensures smooth integration with Terraform configurations, making it an invaluable asset for anyone working with Terraform in diverse environments or within continuous integration and deployment pipelines. Say goodbye to provider management complexities and welcome a seamless Terraform experience with tpm!

The benefit of this approach is that you don't need to store provider binaries within your project directory, which can make your project more lightweight and portable. The providers are managed centrally by tpm, which facilitates version management and ensures that your Terraform code uses the correct versions of providers. It also simplifies the process of sharing your Terraform code with others, as they can install the required providers using tpm when initializing the project on their systems.

Let's install TMP and and see how it works in our example:

Prerequisites:

  1. Install Terraform - here
  2. Install TPM:
  • For GNU/Linux: run yay -S terraform-tpm-bin
  • MacOs via Brew brew install madh93/tap/tpm (Install Brew - here)

tpm_brew

  • Windows via Scoop: curl -L https://github.com/Madh93/tpm/releases/latest/download/tpm_$(uname -s)_$(uname -m).tar.gz | tar -xz -O tpm > /usr/local/bin/tpm then chmod +x /usr/local/bin/tpm (Install Scoop - here)

After installation is done let's check this tool in action:

  1. To install a provider you only need to provide the name. Optionally, you can specify a version by using @. By default, if no version is specified, the latest available version, also known as @latest, will be installed.

You can also specify the architecture and operating system. If not specified, the information from the system where tpm is being executed will be used.

In order to see packages installed type tpm list Optionally, you can specify an output format. Valid output formats are: text (default), json, csv, table. tpm list --output table list_azure

  1. Otherwise, we can install multiple providers at once specifying a example.yml file, making it easier to share and reuse installation requirements: tpm install --from-file example.yml:

from_yml Here is example format for our yml file:

providers:
  - name: hashicorp/aws@3.64.0
  - name: hashicorp/http@3.3.0
    os:
      - linux
      - darwin
    arch:
      - amd64
      - arm64
  - name: hashicorp/random
    os:
      - linux
      - darwin
    arch:
      - amd64
      - arm64
  1. In order to uninstall specified provider we can use the following command: tpm uninstall hashicorp/azurerm@3.65.0:

uninstall_azure

  1. To delete all installed providers you can use following command: tpm purge and type "yes":

purge

You can also visit link here for more information regarding Terraform Provider Manager tool