Open niklasweimann opened 1 year ago
The immediate reason for this error is a type mismatch. network.Id
is a string, while NetworkId
expects an integer. It could be that all is needed is a type conversion, like this:
NetworkId = network.Id.Apply(int.Parse),
If that doesn't help, could you please share the value of network.Id
(e.g. log it, look it up in Pulumi state, or export it as an output0?
Hey 👋
I just tested the .Apply(int.Parse) approach and it worked. So I would suggest updating the documentation since this really confused me as a first time user or change the type of subnet.Network to string since this seems to be an internal Id used by Pulumi only. 😊
Thank you for confirming!
Id
is indeed a special Pulumi property that is always assumed to be a string, while in this case it's an Integer internally. I'll leave the issue open to track the docs and/or conversion improvements.
@mikhailshilkov When using Pulumi YAML this won't work as far as I can tell. I'm fairly new to Pulumi.
Can this type mismatch fixed without any type conversion? This was confusing :)
This same issue is causing problems when trying to use Typescript and type conversion is icky and somewhat defeats the point of the nice TypeScript typing.
The example at https://www.pulumi.com/registry/packages/hcloud/api-docs/networksubnet/ is also invalid due to this issue.
Would love this to be resolved.
What happened?
I want to assign a subnet to an network, but I get an type error.
Steps to reproduce
Even the example from this documentation gives me the exact same type mismatch: https://www.pulumi.com/registry/packages/hcloud/api-docs/networksubnet/
Expected Behavior
I can assign the id of the network to the subnet so the subnet can correctly be created.
Actual Behavior
Type mismatch
Output of
pulumi about
niklasweimann@MacBook-Air-von-Niklas ~/dev/HCloudPulumi main ±✚ pulumi about running 'dotnet build -nologo .' Determining projects to restore...
All projects are up-to-date for restore.
/Users/niklasweimann/dev/HCloudPulumi/Program.cs(16,25): error CS0029: Cannot implicitly convert type 'Pulumi.Output' to 'Pulumi.Input' [/Users/niklasweimann/dev/HCloudPulumi/HCloudPulumi.csproj]
Build FAILED.
/Users/niklasweimann/dev/HCloudPulumi/Program.cs(16,25): error CS0029: Cannot implicitly convert type 'Pulumi.Output' to 'Pulumi.Input' [/Users/niklasweimann/dev/HCloudPulumi/HCloudPulumi.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.42
Determining projects to restore...
All projects are up-to-date for restore.
/Users/niklasweimann/dev/HCloudPulumi/Program.cs(16,25): error CS0029: Cannot implicitly convert type 'Pulumi.Output' to 'Pulumi.Input' [/Users/niklasweimann/dev/HCloudPulumi/HCloudPulumi.csproj]
Build FAILED.
/Users/niklasweimann/dev/HCloudPulumi/Program.cs(16,25): error CS0029: Cannot implicitly convert type 'Pulumi.Output' to 'Pulumi.Input' [/Users/niklasweimann/dev/HCloudPulumi/HCloudPulumi.csproj]
Time Elapsed 00:00:01.42
Enter your passphrase to unlock config/secrets (set PULUMI_CONFIG_PASSPHRASE or PULUMI_CONFIG_PASSPHRASE_FILE to remember): CLI
Version 3.50.2 Go Version go1.19.4 Go Compiler gc
Host
OS darwin Version 13.1 Arch arm64
This project is written in dotnet: executable='/opt/homebrew/bin/dotnet' version='7.0.100'
Current Stack: dev
TYPE URN pulumi:pulumi:Stack urn:pulumi:dev::HCloudPulumi::pulumi:pulumi:Stack::HCloudPulumi-dev pulumi:providers:hcloud urn:pulumi:dev::HCloudPulumi::pulumi:providers:hcloud::default_1_10_1 hcloud:index/network:Network urn:pulumi:dev::HCloudPulumi::hcloud:index/network:Network::Test
Found no pending operations associated with dev
Backend
Name MacBook-Air-von-Niklas.fritz.box URL file://~ User niklasweimann Organizations
Dependencies: NAME VERSION Pulumi 3.50.0 Pulumi.HCloud 1.10.1
Pulumi locates its logs in /var/folders/zb/p_drv5k56nd547h156279cj80000gn/T/ by default warning: Failed to get information about the plugin: failed to discover plugin requirements: 'dotnet build -nologo .' exited with non-zero exit code: 1
Additional context
No response
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).