https://pulumi.com logo
#golang
Title
# golang
b

billowy-needle-56870

01/21/2020, 7:14 PM
Hi. Are there any mods to create custom resources? I am trying to create a custom resource like this, but I have the following error.
Copy code
type Custom struct {
   s *pulumi.ResourceState
}

type CustomArgs struct {
}

// NewBucket registers a new resource with the given unique name, arguments, and options.
func NewCustom(ctx *pulumi.Context,
   name string, args *CustomArgs, opts ...pulumi.ResourceOpt) (*Custom, error) {
   inputs := make(map[string]interface{})
   s, err := ctx.RegisterResource("vendoring:x:customresource", name, true, inputs, opts...)
   if err != nil {
      return nil, err
   }
   return &Custom{s: s}, nil
}

func (b *Custom) URN() pulumi.URNOutput {
   return b.s.URN()
}
error: no resource plugin 'vendoring' found in the workspace or on your $PATH
w

white-balloon-205

01/22/2020, 12:40 AM
CustomResource
is designed for leaf node resources implemented in an external resource provider. Is that what you want? If you want to create resources inside your program, you can use
ComponentResource
. When you define a
CustomResource
, you must put a binary
pulumi-provider-<name>
on your PATH that speaks the Pulumi provider gRPC protocol. It will be loaded to handle CRUD operations against the resource you have defined. More about this proces abstractly here: https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/ Can you share more about what you are trying to do? (aside - as noted in https://pulumi-community.slack.com/archives/CCWP5TJ5U/p1573603543035700 - which I also just pinned to the channel - there are some very major overhauls of the Go provider happening right now to get ready for GA, so you may see things in flux over the next few weeks)
b

billowy-needle-56870

01/22/2020, 8:56 AM
I'm trying to create a library like pulumi/awsx. Finally It's works, but I changed this line
ctx.RegisterResource("vendoring:x:customresource", name, true, inputs, opts)
by this one
ctx.RegisterResource("vendoring:x:customresource", name, false, inputs, opts)
7 Views