In a .tf file, in a required_providers block all the Terraform providers will be listed there. When terraform plan is executed the providers will be pull from a registry or cache if defined. But how to test a provider that’s not published to a registry yet?
Say the provider is called raynix so normally we’d have this in .tf:
# main.tf
terraform {
required_providers {
raynix = {
source = "raynix-info/raynix"
}
}
...
}
provider "raynix" {}Terraform provides a local override to pull the provider which is an executable binary from a local path instead. The override should be in ~/.terraformrc file
# ~/.terraformrc
provider_installation {
dev_overrides {
# the binary should be called terraform-provider-raynix, at the below place
"raynix-info/raynix" = "/opt/raynix-info"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}And there will be warning like this when executing:
16:05:09.490 STDOUT terraform: │ Warning: Provider development overrides are in effect 16:05:09.490 STDOUT terraform: │ 16:05:09.490 STDOUT terraform: │ The following provider development overrides are set in the CLI 16:05:09.490 STDOUT terraform: │ configuration: 16:05:09.490 STDOUT terraform: │ - raynix-info/raynix in ../../../opt/raynix-info 16:05:09.490 STDOUT terraform: │ 16:05:09.490 STDOUT terraform: │ Skip terraform init when using provider development overrides. It is not 16:05:09.490 STDOUT terraform: │ necessary and may error unexpectedly.
With Terragrunt, there’s an extra step required:
terragrunt plan --no-auto-init
Because terragrunt will do terraform init under the hood automatically and will fail because of the local override.
🙂
