Writing a custom provider

535 views
Skip to first unread message

Jack Bruno

unread,
Nov 12, 2014, 11:27:55 AM11/12/14
to terrafo...@googlegroups.com
Hello,

I am trying to write a custom provider using the tutorial found here https://hashicorp.com/blog/terraform-custom-providers.html

I am getting an error on the first build step.

go build -o terraform-provider-vcd

Here is the output.

/dropbox/go/src/github.com/jzbruno/terraform-provider-vcd$ go build -o terraform-provider-vcd
# github.com/hashicorp/terraform/config
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_lex.go:25: undefined: exprSymType
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_lex.go:41: undefined: COMMA
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_lex.go:43: undefined: LEFTPAREN
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_lex.go:45: undefined: RIGHTPAREN
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_lex.go:53: undefined: exprSymType
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_lex.go:80: undefined: IDENTIFIER
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_lex.go:83: undefined: exprSymType
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_lex.go:103: undefined: STRING
/dropbox/go/src/github.com/hashicorp/terraform/config/expr_parse.go:25: undefined: exprParse
/dropbox/go/src/github.com/jzbruno/terraform-provider-vcd$

Any ideas on what I am missing? Source can be found here https://github.com/jzbruno/terraform-provider-vcd

Mitchell Hashimoto

unread,
Nov 12, 2014, 11:32:16 AM11/12/14
to Jack Bruno, <terraform-tool@googlegroups.com>
Jack,

Go to $GOPATH/github.com/hashicorp/terraform and run `make`. This
should fix all this.

The issue is that the parser that is generated is not generated yet.

Best,
Mitchell
> --
> You received this message because you are subscribed to the Google Groups
> "Terraform" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to terraform-too...@googlegroups.com.
> To post to this group, send email to terrafo...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/terraform-tool/b0b1361b-911f-4c7f-9b29-0570d086a908%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jack Bruno

unread,
Nov 12, 2014, 12:00:13 PM11/12/14
to terrafo...@googlegroups.com, jzb...@gmail.com
Mitchell,

Thanks. That got me past the first error but brought up a few questions.

1. I had to "go get" a bunch of dependencies for the make to work. Is this normal? Is there a cleaner way to pull down all of them?

2. I got the following error on my provider build. Is the tutorial outdated? It appears that plugin.Serve is not meant to be used as the tutorial shows.

/dropbox/go/src/github.com/jzbruno/terraform-provider-vcd/main.go:8: cannot use Provider() (type *schema.Provider) as type *plugin.ServeOpts in argument to plugin.Serve

Jack

Jack Bruno

unread,
Nov 12, 2014, 11:45:47 PM11/12/14
to terrafo...@googlegroups.com, jzb...@gmail.com
OK.

1. Found the development instructions in the repo readme. https://github.com/hashicorp/terraform#developing-terraform
2. From searches I gather this changed after 0.2.2. Need to pass ServerOpts with a ProviderFunc.

Jack

Bill Wanjohi

unread,
Jan 25, 2015, 5:17:28 PM1/25/15
to terrafo...@googlegroups.com, jzb...@gmail.com
If anyone else runs into Jack's second problem, I followed his lead, found https://github.com/whitepages/terraform-provider-dummy, and got my dummy running with the changes shown in this patch:

diff --git a/main.go b/main.go
index dfc33ec..5ecf31e 100644
--- a/main.go
+++ b/main.go
@@ -2,8 +2,13 @@ package main

 import (
 )

 func main() {
-       plugin.Serve(Provider())
+       plugin.Serve(&plugin.ServeOpts{
+               ProviderFunc: func() terraform.ResourceProvider {
+                       return Provider()
+               },
+       })
 }
diff --git a/provider.go b/provider.go
index 97757db..fed15c8 100644
--- a/provider.go
+++ b/provider.go
@@ -2,9 +2,10 @@ package main

 import (
 )

-func Provider() *schema.Provider {
+func Provider() terraform.ResourceProvider {
        return &schema.Provider{
                ResourcesMap: map[string]*schema.Resource{},
Reply all
Reply to author
Forward
0 new messages