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

most-portugal-2672

02/03/2022, 2:12 PM
Hi there, I'm trying out this piece of code from https://www.pulumi.com/registry/packages/azure-native/api-docs/network/virtualnetwork/#create-virtual-network-with-subnet:
Copy code
_, err := network.NewVirtualNetwork(ctx, "virtualNetwork", &network.VirtualNetworkArgs{
			AddressSpace: &network.AddressSpaceArgs{
				AddressPrefixes: pulumi.StringArray{
					pulumi.String("10.0.0.0/16"),
				},
			},
			Location:          pulumi.String("eastus"),
			ResourceGroupName: pulumi.String("rg1"),
			Subnets: []network.SubnetArgs{
				&network.SubnetArgs{
					AddressPrefix: pulumi.String("10.0.0.0/24"),
					Name:          pulumi.String("test-1"),
				},
			},
			VirtualNetworkName: pulumi.String("test-vnet"),
		})
For the "Subnets" field, however, the
network.SubnetArgs
type doesn't seem qualify as a
network.SubnetTypeArrayInput
because it does implement a method called `ToSubnetTypeArrayOutput`:
b

billions-judge-9412

02/03/2022, 2:18 PM
I have the EXACT same problem with postgresservers. Their example for it is just broken on their website. I realize this doesn't help but im honestly a little sad to see it be a widespread issue :(
I have even submitted an issue on this, in their github: https://github.com/pulumi/pulumi-azure-native/issues/1472 You could possibly add your case to it. They could be related
m

most-portugal-2672

02/03/2022, 4:12 PM
Nice one mate - looks like whatever they use to automatically codegen these things might be missing methods. I've voted your issue up.
I ended up filing a bug as well: https://github.com/pulumi/pulumi-azure-native/issues/1479. Thanks for the tip.
i

important-appointment-55126

02/03/2022, 4:46 PM
given that it wants a
SubnetTypeArrayInput
, this compiles for me…
Copy code
_, err := network.NewVirtualNetwork(ctx, "virtualNetwork", &network.VirtualNetworkArgs{
                        AddressSpace: &network.AddressSpaceArgs{
                                AddressPrefixes: pulumi.StringArray{
                                        pulumi.String("10.0.0.0/16"),
                                },
                        },
                        Location:          pulumi.String("eastus"),
                        ResourceGroupName: pulumi.String("rg1"),
                        Subnets: network.SubnetTypeArray{
                                &network.SubnetTypeArgs{
                                        AddressPrefix: pulumi.String("10.0.0.0/24"),
                                        Name:          pulumi.String("test-1"),
                                },
                        },
                        VirtualNetworkName: pulumi.String("test-vnet"),
                })
🙌 1
(untested beyond running go build)
m

most-portugal-2672

02/03/2022, 5:00 PM
Thank you @important-appointment-55126 - that was a simple fix ! Much appreciated !! Still a noob learning this API 🙂
i

important-appointment-55126

02/03/2022, 5:01 PM
great! Glad it worked - looks like they need a bug fix on the docs eh?
m

most-portugal-2672

02/03/2022, 5:01 PM
Yes - the docs need to be fixed - correct.
a

astonishing-solstice-53645

02/03/2022, 5:15 PM
They were quick to merge a GHA docs PR for me so perhaps worth raising?
m

most-portugal-2672

02/03/2022, 5:16 PM
That's a great idea yes!
6 Views