https://pulumi.com logo
#typescript
Title
# typescript
p

prehistoric-fish-76119

02/08/2024, 11:35 AM
Hi. How to create
hcloud
NetworkSubnet correct way linked to Network, looks like docs examples outdated (https://www.pulumi.com/registry/packages/hcloud/api-docs/networksubnet/):
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const mynet = new hcloud.Network("mynet", {ipRange: "10.0.0.0/8"});
const foonet = new hcloud.NetworkSubnet("foonet", {
    networkId: mynet.id,
    type: "cloud",
    networkZone: "eu-central",
    ipRange: "10.0.1.0/24",
});
Because Network
network.id
is Output<string> and NetworkSubnet networkId is Input<number>. The same situation in Go version.
l

little-cartoon-10569

02/08/2024, 6:38 PM
From looking at the bridged provider, it looks like the network id really is a number. The simplest way to cast it is
network.id.apply((idstring) => +idstring)
.
p

prehistoric-fish-76119

02/08/2024, 7:03 PM
@little-cartoon-10569 Thanks. Already implemented similar solution
network.id.apply(Number.parseFloat)