Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Developing the Provider #149

Open
bukowa opened this issue Sep 27, 2022 · 5 comments
Open

Developing the Provider #149

bukowa opened this issue Sep 27, 2022 · 5 comments

Comments

@bukowa
Copy link

bukowa commented Sep 27, 2022

Hey, I cannot find any information about actually using this provider in my configuration files.
For ex. after building the binary what should I do now to use that provider in my terraform config without actually publishing it into registry?

hashicorp/terraform#25906
hashicorp/terraform#26123
https://discuss.hashicorp.com/t/easiest-way-to-use-a-local-custom-provider-with-terraform-0-13/12691

@bukowa
Copy link
Author

bukowa commented Sep 27, 2022

Place in your .terraformrc file this config:

provider_installation {
  filesystem_mirror {
    path    = "/usr/share/.terraform.d/providers"
    include = ["terraform.local/*/*"]
  }
  direct {
    exclude = ["terraform.local/*/*"]
  }
}

Place your binary (depending on your OS and ARCH) in /usr/share/.terraform.d/providers/terraform.local/local/myplugin/1.0.0/windows_amd64/terraform-provider-myplugin_v1.0.0.exe

Use in terraform config:

terraform {
  required_providers {
    myplugin= {
      source = "terraform.local/local/myplugin"
      version = "~> 1.0.0"
    }
  }
}

Keep in mind you may encounter unknown errors while using a module that points to provider with the same name but different binary (even if they're exactly same binaries even with matching checksum/hash).

@lucymhdavies
Copy link

lucymhdavies commented Oct 7, 2022

Thanks @bukowa ! That's just the info I was looking for.

Would be super useful to get that added to the bottom of the README if you're up for PR-ing it :)
https://github.com/hashicorp/terraform-provider-scaffolding/blob/main/README.md

(I'm part of Hashi, but this ain't my team)

@bukowa
Copy link
Author

bukowa commented Oct 9, 2022

Hey there's also nice Makefile example that worked out of the box for me while using Linux (my question was asked while i were working on windows):

https://github.com/kreuzwerker/terraform-provider-docker/blob/bdaec499d829c7b7d351109191e04767b123c570/GNUmakefile#L23

@bflad
Copy link
Contributor

bflad commented Oct 10, 2022

Hi folks 👋

In addition to manually copying the provider binary for local installation into a conventional directory, you can also use the dev_overrides provider installation configuration. This allows you to build and put the binary in any directory, such as GOBIN if you would like to just run go install in your provider codebase.

Additional references:

@lucymhdavies
Copy link

I was looking at dev_overrides a while ago, but wasn't sure quite how it works.

If I'm understanding your comment, and that second link, then it's as simple as...

provider_installation {
  dev_overrides {
    "local/foo" = "<insert ${GOBIN} here>"
  }
}

Nice! That makes things MUCH easier :D

(I'd seen https://www.terraform.io/plugin/debugging, but I'd not seen the https://learn.hashicorp.com link before. That's super helpful)

So then, I think it makes sense for us to reference that page in this repo's README file

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants