Hi. I’m trying to create a new network on Hetzner ...
# golang
b
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:
Copy code
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
Hello! AFAIK, unless you are using the automation API, you need to run the go code using the
pulumi up
command.
b
Oh, I see. Thanks! I’ll look into that.
n
did you execute the command
pulumi new
in order to initialize your Pulumi project ?
b
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
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
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
Yeh it'll just pick up the first thing on path