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

numerous-thailand-80976

06/28/2021, 2:31 AM
Hey!, I’m having a probably very dumb problem, I’m using the Google Native SDK and I’m trying to create a VPC, here’s the code snippet for that:
Copy code
vpc, err := network.NewNetwork(ctx, projectID+"-vpc-"+config.Name, &network.NetworkArgs{
		AutoCreateSubnetworks: pulumi.Bool(config.AutocreateSubnets),
		Name:                  pulumi.String(config.Name),
		RoutingConfig: &network.NetworkRoutingConfigArgs{
			RoutingMode: ?
		},
	})
I’m having an issue with the ?,
RoutingMode
is an object of
*(network,NetworkRoutingConfigArgs).RoutingMode
type for which there are 2 constants `network.NetworkRoutingConfigRoutingModeGlobal`and
network.NetworkRoutingConfigRoutingModeRegional
. I’ve tried the following but all are rejected by the compiler:
Copy code
&network.NetworkRoutingConfigRoutingModeGlobal
&network.NetworkRoutingConfigRoutingMode{ network.NetworkRoutingConfigRoutingModeGlobal }
&network.NetworkRoutingConfigRoutingMode(network.NetworkRoutingConfigRoutingModeGlobal)
Does anyone know how I can pass the constant to the
RoutingMode
field?
b

bored-table-20691

06/28/2021, 2:37 AM
Try assigning it to a local variable and then take the address of that with &. Go doesn’t like taking addresses of constants
n

numerous-thailand-80976

06/28/2021, 11:41 AM
Ahhh….I knew it was a dumb problem, that did it
Thanks!
3 Views