https://pulumi.com logo
Title
b

bored-vr-79323

04/17/2023, 9:01 AM
Hi. I’m trying to create a new network on Hetzner with code taken from this pulumi-hcloud go example but instead of
.Run
I’m using
.RunErr
to get errors:
package main

import (
	"<http://github.com/pulumi/pulumi-hcloud/sdk/go/hcloud|github.com/pulumi/pulumi-hcloud/sdk/go/hcloud>"
	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
	"log"
)

func main() {

	err := pulumi.RunErr(func(ctx *pulumi.Context) error {
		log.Println("Creating new network...")

		network, err := hcloud.NewNetwork(ctx, "demo-network", &hcloud.NetworkArgs{
			IpRange: pulumi.String("10.0.10.0/24"),
			Name:    pulumi.String("demo-project"),
		})
		if err != nil {
			return err
		}

		ctx.Export("networkName", network.Name)
		return nil
	})

	if err != nil {
		log.Fatal("Error creating network: ", err)
	}
}
When I build and run the binary, I get an error:
missing project name
. Where does the project name go? Don’t I already give it a project name “demo-network”? The docs call that parameter a “unique name”. So I’m not sure.
n

nice-guitar-7761

04/17/2023, 9:10 AM
Hello! AFAIK, unless you are using the automation API, you need to run the go code using the
pulumi up
command.
b

bored-vr-79323

04/17/2023, 9:13 AM
Oh, I see. Thanks! I’ll look into that.
n

nice-guitar-7761

04/17/2023, 9:42 AM
did you execute the command
pulumi new
in order to initialize your Pulumi project ?
b

bored-vr-79323

04/17/2023, 12:23 PM
I didn’t. I’m trying to do everything just by opening the Go binary, without typing anything into the CLI. I guess executing
pulumi new
on the CLI goes with
pulumi.Run
e

echoing-dinner-19531

04/17/2023, 12:28 PM
It does, but it sets up the environment to tell pulumi.Run how to connect to the engine that the CLI is running
You need the engine running somehow, either via the CLI or automation api (which just manages the CLI invoke for you)
b

bored-vr-79323

04/17/2023, 2:42 PM
Works now with automation API. I’m downloading a Pulumi release directly into the project dir and adding it to
PATH
. Looks like Pulumi picks it up from there. 🙂 Thanks, everyone
e

echoing-dinner-19531

04/17/2023, 2:43 PM
Yeh it'll just pick up the first thing on path