HarperDB-Add-Ons / terraform-provider-harperdb

Mozilla Public License 2.0
3 stars 0 forks source link

How do I initialize the harperdb provider? #2

Closed gordonmurray closed 1 year ago

gordonmurray commented 1 year ago

I have a local copy of HarperDB running and connected to the HarperDB studio using an ngrok tunnel.

After reading this post on the HaperDB Terraform Provider I was excited to try it out, but I am unable to get the provider initialized.

I have read the readme on https://github.com/HarperDB-Add-Ons/terraform-provider-harperdb and from what I can tell, the provider isn't on the Hashicorp registry, so I can't use the following?

terraform {
  required_version = "1.3.7"

  required_providers {
    harperdb = {
      source = "registry.terraform.io/harperdb/harperdb"
    }
  }
}

I have cloned the repo and used go install to compile the provider. I placed the output in to the folder for local terraform providers at:

~/.terraform.d/plugins/harperdb

I tried to initialize the local provider using the following:

terraform {
  required_version = "1.3.7"
  required_providers {
    harperdb = {
      source = "terraform.local/harperdb/harperdb"
    }
  }
}

However I get the following error:

│ Could not retrieve the list of available versions for provider terraform.local/harperdb/harperdb: provider terraform.local/harperdb/harperdb was not found in any of the search locations

My ~/.terraformrc file contains the following to specify the plugins folder:

provider_installation {
  filesystem_mirror {
    path    = "/home/gordon/.terraform.d/plugins/"
  }
  direct {
    exclude = ["terraform.local/*/*"]
  }
}

I have tried a few variations of this and I am unable to terraform init the provider, can you provider any guidance?

moredhel commented 1 year ago

Hi @gordonmurray ,

Thanks for giving it a spin! I'm sorry it didn't work out for you, let me see if I can help you out.

Can you try the following in your terraformrc, and you shouldn't need to do a terraform plan.


provider_installation {

  dev_overrides {
      "registry.terraform.io/harperdb/harperdb" = "/home/gordon/.terraform.d/plugins/"
  }

  # 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 {}
}

Do let me know if that works.

Regarding your other queries;

You can look in the testing directory which has a provider.tf already configured.

gordonmurray commented 1 year ago

Hi @moredhel Thanks for responding.

Thanks for the updated terraformrc content, that seems to work.

you shouldn't need to do a terraform plan.

Ah, I see what you mean now. I receive the following output now:

Skip terraform init when using provider development overrides. It is not necessary and may error unexpectedly.

Thanks for pointing out the testing folder. I tried to use the schema example and its working well.

Theres another issue related to creating a Role, but I can open another issue for that: https://github.com/HarperDB-Add-Ons/terraform-provider-harperdb/issues/3