Terraform provider plugin tutorial invalid data source

Hi I am going through the terraform provider tutorial. I made it to the section where you make a temporary Data Source. but I keep getting the following from running the terraform plan command.

[vagrant@terraform-tutorial provider-install-verification]$ terraform plan
│ Warning: Provider development overrides are in effect
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp.com/edu/hashicups in /home/vagrant/golang/go/bin
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become
│ incompatible with published releases.
│ Error: Invalid data source
│   on main.tf line 11, in data "hashicups_coffees" "example":
│   11: data "hashicups_coffees" "example" {}
│ The provider hashicorp.com/edu/hashicups does not support data source "hashicups_coffees".
[vagrant@terraform-tutorial provider-install-verification]$

as far as I can tell I followed the tutorial correctly. but its not finding the datasource. Is there a way to debug this?

Hi @bwolfehcm :wave:

Are you referring to this step Configure provider client | Terraform | HashiCorp Developer?

Without seeing the code that you have in place, it’s a little difficult to be sure, but I think the most likely explanation is that you may not have set-up the DataSources within provider.go:

func (p *hashicupsProvider) DataSources(_ context.Context) []func() datasource.DataSource {
	return []func() datasource.DataSource{

Implementation of the temporary data source itself is described in the previous step - Configure provider client | Terraform | HashiCorp Developer.

You can debug the provider by starting it in debug mode - Plugin Development - Debugging Providers | Terraform | HashiCorp Developer

I’m using GoLand, so I typically set-up debugging as follows:

Starting a debug session, will then output something like the following:


You can then execute:

export TF_REATTACH_PROVIDERS='{"hash..............

Then you can set break points and run terraform plan.

ok interesting. for some reason running the debug in goland reset the terraform process. Its working now.
i’m not sure what I did to fix it, but my code was correct. I guess the older version got cached or something.
I ended up deleteing the terraform-provider-hashicups binary which gets put in the golang/go/bin directory and reran the “go install .” command

So maybe it forced it to update the binary file.

After that I was running into some schema loading issue.

Error: Failed to load plugin schemas
│ Error while loading schemas for plugin components: Failed to obtain provider
│ schema: Could not load the schema for provider hashicorp.com/edu/hashicups:
│ failed to instantiate provider "hashicorp.com/edu/hashicups" to obtain
│ schema: Reattachment process not found..

I had to unset the TF_REATTACH_PROVIDERS variable for it to load the schema in the regular terraform commandline process.

I did find that setting TF_LOG=DEBUG environment variable was helpful as well.