Skip to content

Build and Install The Provider Manually

Hang Yu edited this page May 27, 2023 · 4 revisions

Build and Install The Provider Manually

⚠️ The master version needs to be compiled and installed manually and can only be used for testing. Please use the latest release version in production.

1. Build the provider

Clone repository

git clone [email protected]:harvester/terraform-provider-harvester

Enter the provider directory and build the provider

This will build the provider and put the provider binary in ./bin.

cd terraform-provider-harvester
make

2. Install the provider

The default location for locally-installed providers is one of the following, depending on which operating system you are running Terraform under:

  • Windows: %APPDATA%\terraform.d\plugins
  • All other systems: ~/.terraform.d/plugins

Place the provider into the plugins directory, for example:

PROVIDER="harvester"
VERSION="0.0.0-dev"
OS_PLATFORM=$(uname -sp | tr '[:upper:] ' '[:lower:]_' | sed 's/x86_64/amd64/' | sed 's/i386/amd64/' | sed 's/arm/arm64/')
PROVIDERS_DIR=$HOME/.terraform.d/plugins/terraform.local/local/${PROVIDER}
PROVIDER_DIR=${PROVIDERS_DIR}/${VERSION}/${OS_PLATFORM}
mkdir -p ${PROVIDER_DIR}
cp bin/terraform-provider-${PROVIDER} ${PROVIDER_DIR}/terraform-provider-${PROVIDER}_v${VERSION}

After placing it into your plugins directory, copy and paste this code into your Terraform configuration. Then, run terraform init to initialize it.

terraform {
  required_providers {
    harvester = {
      source = "terraform.local/local/harvester"
      version = "0.0.0-dev"
    }
  }
}

provider "harvester" {
  # Configuration options
}