Test unreleased providers

Hey there!

I am the main developer of the Cobbler Terraform Provider. The Provider is SDKv2 based. I am starting to slowly get ready for a new release and wanted to do some manual explorative tests for the new version of my provider.

However, I am unable to find any mention of how to use a non-published version of a provider. Can anyone give me any pointers?

The documentation mentions only how to do Unit and Integration testing: Plugin Development - Testing | Terraform | HashiCorp Developer

Thanks for your help,
Enno aka SchoolGuy

Are you testing an unpublished provider version, or a provider which doesn’t exist on the registry at all?

Working with a completely unpublished provider is trickier, because terraform init will go looking to the registry, and fail.

For published providers, my preferred approach is to set the dev_overrides configuration in ~/.terraformrc:

provider_installation {
  dev_overrides {
    # Note that this is the directory path, not the path to the actual binary.
    # The binary should be named terraform-provider-cobbler.
    "cobbler/cobbler" = "/path/to/provider/binary/dir"
  }
  direct {}
}

In my case, it points at ~/go/bin, which is where the provider lands when I run go install.

Nearly everything works normally this way.

If the provider doesn’t exist at all, I believe there are two options:

  • set the config file as above, and never run terraform init. This complicates tests which require multiple providers.
  • specify a version in the project’s required_providers stanza and drop the provider binary at the path where terraform init would put it within the test project:
.terraform
└── providers
    └── registry.terraform.io
        └── cobbler
            └── cobbler
                └── 1.2.3
                    └── darwin_arm64
                        └── terraform-provider-cobbler_v1.2.3

This way, you preempt terraform init from reaching out to a registry looking for the latest binary.

It’s been a while since I’ve been in the position of working on an un-published provider, so I may be misremembering things a bit.

1 Like

That worked marvellous! My provider is indeed already published, so I could go the easy route with the .terraformrc file.