Skip to content

id from some resources not assignable to resourceId #671

Description

@pmaier983

Describe what happened

The id you get from the Network resource object is not assignable to networkId of a NetworkSubnet.
The id you get from the Server resource object is also not assignable to the serverId of a FloatingIpAssignment.

Sample program

const network = new hcloud.Network("network", {
  name: NETWORK_NAME,
  ipRange: "10.0.1.0/24",
})

// Create a Hetzner subnet
const subnet = new hcloud.NetworkSubnet("subnet", {
  networkId: network.id,
  networkZone: "us-east",
  type: "cloud",
  ipRange: "10.0.1.0/24",
})

Error: Type 'Output<string>' is not assignable to type 'Input<number>'. Type 'Output<string>' is not assignable to type 'OutputInstance<number>'. Types of property 'apply' are incompatible. Type '{ <U>(func: (t: string) => Promise<U>): Output<U>; <U>(func: (t: string) => OutputInstance<U>): Output<U>; <U>(func: (t: string) => U): Output<...>; }' is not assignable to type '{ <U>(func: (t: number) => Promise<U>): Output<U>; <U>(func: (t: number) => OutputInstance<U>): Output<U>; <U>(func: (t: number) => U): Output<...>; }'. Types of parameters 'func' and 'func' are incompatible. Types of parameters 't' and 't' are incompatible. Type 'string' is not assignable to type 'number'.ts(2322) networkSubnet.d.ts(116, 5): The expected type comes from property 'networkId' which is declared here on type 'NetworkSubnetArgs'

// Create a Hetzner server instance.
const instance = new hcloud.Server("instance", {
  name: INSTANCE_NAME,
  serverType: "cpx11",
  image: "docker-ce",
  networks: [{ networkId: networkId }],
  userData: metadataStartupScript,
  firewallIds: [firewallId],
})

// Step 3: Associate Floating IP to Server
const associatedIp = new hcloud.FloatingIpAssignment("main", {
  floatingIpId: ipId,
  serverId: instance.id,
})

Error: Type 'Output<string>' is not assignable to type 'Input<number>'. Type 'Output<string>' is not assignable to type 'OutputInstance<number>'. Types of property 'apply' are incompatible. Type '{ <U>(func: (t: string) => Promise<U>): Output<U>; <U>(func: (t: string) => OutputInstance<U>): Output<U>; <U>(func: (t: string) => U): Output<...>; }' is not assignable to type '{ <U>(func: (t: number) => Promise<U>): Output<U>; <U>(func: (t: number) => OutputInstance<U>): Output<U>; <U>(func: (t: number) => U): Output<...>; }'. Types of parameters 'func' and 'func' are incompatible. Types of parameters 't' and 't' are incompatible. Type 'string' is not assignable to type 'number'.ts(2322) floatingIpAssignment.d.ts(92, 5): The expected type comes from property 'serverId' which is declared here on type 'FloatingIpAssignmentArgs'

Log output

If you just try and ignore the TS error:
Running program 'packages/pulumi-blog-infra/' failed with an unhandled exception: TSError: ⨯ Unable to compile TypeScript: index.ts(28,3): error TS2322: Type 'Output<string>' is not assignable to type 'Input<number>'. Type 'Output<string>' is not assignable to type 'OutputInstance<number>'. Types of property 'apply' are incompatible. Type '{ <U>(func: (t: string) => Promise<U>): Output<U>; <U>(func: (t: string) => OutputInstance<U>): Output<U>; <U>(func: (t: string) => U): Output<...>; }' is not assignable to type '{ <U>(func: (t: number) => Promise<U>): Output<U>; <U>(func: (t: number) => OutputInstance<U>): Output<U>; <U>(func: (t: number) => U): Output<...>; }'. Types of parameters 'func' and 'func' are incompatible. Types of parameters 't' and 't' are incompatible. Type 'string' is not assignable to type 'number'.

If you try and cast to a Number: networkId: Number(network.id), (I replaced the actual network ID's with 1111 in the error message just in case):
error: sdk-v2/provider2.go:520: sdk.helper_schema: network with ID '-11111' not found (not_found, bc7256f22cc4b0b84cac0a6e338ec5c2): provider=hcloud@1.21.1 error: 1 error occurred: * network with ID '-11111' not found (not_found, bc7256f22cc4b0b84cac0a6e338ec5c2)

Affected Resource(s)

hcloud.FloatingIpAssignment and hcloud.NetworkSubnet but I would bet there are more!

Output of pulumi about

CLI
Version 3.144.1
Go Version go1.23.4
Go Compiler gc

Plugins
KIND NAME VERSION
resource gcp 8.10.0
resource hcloud 1.21.1
language nodejs 3.144.1

Host
OS darwin
Version 14.6.1
Arch x86_64

This project is written in nodejs: executable='/Users/phillipmaier/.nvm/versions/node/v20.18.1/bin/node' version='v20.18.1'

Current Stack: pmaier983/pulumi-blog-infra/dev

TYPE URN
pulumi:pulumi:Stack urn:pulumi:dev::pulumi-blog-infra::pulumi:pulumi:Stack::pulumi-blog-infra-dev
pulumi:providers:hcloud urn:pulumi:dev::pulumi-blog-infra::pulumi:providers:hcloud::default_1_21_1
hcloud:index/floatingIp:FloatingIp urn:pulumi:dev::pulumi-blog-infra::hcloud:index/floatingIp:FloatingIp::floating-ip
pulumi:providers:gcp urn:pulumi:dev::pulumi-blog-infra::pulumi:providers:gcp::default_8_10_0
hcloud:index/network:Network urn:pulumi:dev::pulumi-blog-infra::hcloud:index/network:Network::network
hcloud:index/firewall:Firewall urn:pulumi:dev::pulumi-blog-infra::hcloud:index/firewall:Firewall::firewall
gcp:dns/recordSet:RecordSet urn:pulumi:dev::pulumi-blog-infra::gcp:dns/recordSet:RecordSet::blog-www-record-dev
gcp:dns/recordSet:RecordSet urn:pulumi:dev::pulumi-blog-infra::gcp:dns/recordSet:RecordSet::blog-backend-record-dev
gcp:dns/recordSet:RecordSet urn:pulumi:dev::pulumi-blog-infra::gcp:dns/recordSet:RecordSet::blog-root-record-dev

Found no pending operations associated with dev

Backend
Name pulumi.com
URL https://app.pulumi.com/pmaier983
User pmaier983
Organizations pmaier983
Token type personal

Additional context

I currently have two projects, both using GCP and I was trying to convert them to use hetzner for some cost savings!

https://github.com/pmaier983/Blog/blob/main/packages/pulumi-blog-infra/index.ts

https://github.com/pmaier983/Blog/blob/main/packages/pulumi-blog/index.ts

Merry Christmas, and no need to rush a fix out!

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-upstreamThe issue cannot be resolved without action in another repository (may be owned by Pulumi).kind/bugSome behavior is incorrect or out of spec

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions