Hello Pulumi community, Im creating DNS records an...
# general
s
Hello Pulumi community, Im creating DNS records and zones using pulumi cloudflare provider, im getting an issue when trying to get the zone Id output as an input for my record creation, something very simple like
Copy code
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		conf := config.New(ctx, "")
		accountID := conf.Require("accountId")
		
		zone, err := cloudflare.NewZone(ctx, "<http://zone.io|zone.io>", &cloudflare.ZoneArgs{
			AccountId: pulumi.String(accountID),
			Plan:      pulumi.String("free"),
			Zone:      pulumi.String("<http://zone.io|zone.io>"),
		}, pulumi.Protect(true))
		if err != nil {
			return err
		}
		_, err := cloudflare.NewRecord(ctx, "test_record", &cloudflare.RecordArgs{
			ZoneId: zone.Id,
			Name:    pulumi.String("test"),
			Value:   pulumi.String("0.0.0.0"),
			Type:    pulumi.String("A"),
			Ttl:     <http://pulumi.Int|pulumi.Int>(1),
			Proxied: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})

}
Im constantly getting the error
./main.go:56:21: zone.Id undefined (type *cloudflare.Zone has no field or method Id)
But as per provider documentation the Id output actually exists and if I change Zone.Id for another output like zone.Status it works , Could this be a provider bug or am I doing something wrong?
b
zone.ID()
s
Have tried that but it results into another issue
Copy code
/main.go:56:16: cannot use zone.ID (value of type func() pulumi.IDOutput) as type pulumi.StringInput in struct literal:
        func() pulumi.IDOutput does not implement pulumi.StringInput (missing ElementType method)
b
This compiles for me
Copy code
zone, err := cloudflare.NewZone(ctx, "<http://zone.io|zone.io>", &cloudflare.ZoneArgs{
			AccountId: pulumi.String("foo"),
			Plan:      pulumi.String("free"),
			Zone:      pulumi.String("<http://leebriggs.io|leebriggs.io>"),
		})
		if err != nil {
			return err
		}

		record, err := cloudflare.NewRecord(ctx, "test_record", &cloudflare.RecordArgs{
			ZoneId:  zone.ID(),
			Name:    pulumi.String("test"),
			Value:   pulumi.String("0.0.0.0"),
			Type:    pulumi.String("A"),
			Ttl:     <http://pulumi.Int|pulumi.Int>(1),
			Proxied: pulumi.Bool(true),
		})
I think you’re missing the func return, so you’re passing
zone.ID
instead of
zone.ID()
s
You right, works now! Thanks for your help, appreciate it
b
if you aren’t using an IDE like vscode, it’ll really help you catch errors like this and fix them automatically
s
Cool, is that a pulumi extension for Vscode¿
b
it’s just the standard Go extension
👍 1