Hi all, I’m trying to create an object with `Args`...
# golang
b
Hi all, I’m trying to create an object with
Args
which depends on a
StringInput
. This is what I do:
Copy code
scheduling := args.ProvisioningModel.ToStringOutput().ApplyT(func(model string) *compute.RegionInstanceTemplateSchedulingArgs {
		if model == "SPOT" {
			return &compute.RegionInstanceTemplateSchedulingArgs{
				AutomaticRestart:  pulumi.Bool(false),
				Preemptible:       pulumi.Bool(true),
				ProvisioningModel: pulumi.String("SPOT"),
			}
		}
		return nil
	}).(compute.RegionInstanceTemplateSchedulingPtrInput)
Then I use in
compute.NewRegionInstanceTemplate
Copy code
vm.RegionInstanceTemplate, err = compute.NewRegionInstanceTemplate(ctx, name, &compute.RegionInstanceTemplateArgs{
		Project:     args.Project,
		Region:      args.Region,
		MachineType: args.VmType,
		Scheduling:  scheduling.ToRegionInstanceTemplateSchedulingPtrOutput(),
...
But on
update
I get an error
Copy code
interface conversion: **compute.RegionInstanceTemplateSchedulingArgs is not internal.Input: missing method ElementType
Looks like I created a pointer to a pointer? I’m reading the module’s source code to understand typing but getting very confused. How to do it right?
c
At first glance, it looks like
scheduling
is already a PtrOutput as you output it from the
Apply
function, so you likely don't need to call
ToRegionInstanceTemplateSchedulingPtrOutput()
. Perhaps just pass in the instance variable
scheduling