Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subnet cannot be assigned to network #158

Open
niklasweimann opened this issue Dec 22, 2022 · 6 comments
Open

Subnet cannot be assigned to network #158

niklasweimann opened this issue Dec 22, 2022 · 6 comments
Labels
kind/enhancement Improvements or new features

Comments

@niklasweimann
Copy link

What happened?

I want to assign a subnet to an network, but I get an type error.

Steps to reproduce

var network = new Pulumi.HCloud.Network("Test", new Pulumi.HCloud.NetworkArgs
        {
            IpRange = "10.0.1.0/16",
            Name = "Test-Network",
        });
        var subnet = new Pulumi.HCloud.NetworkSubnet("Test-Subnet-1", new Pulumi.HCloud.NetworkSubnetArgs
        {
            IpRange = "10.0.1.0/24",
            NetworkId = network.Id,
            NetworkZone = "eu-central"
        });

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]

0 Warning(s)

1 Error(s)

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).

@niklasweimann niklasweimann added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 22, 2022
@mikhailshilkov
Copy link
Member

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?

@mikhailshilkov mikhailshilkov added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Dec 26, 2022
@niklasweimann
Copy link
Author

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. 😊

@mikhailshilkov mikhailshilkov added kind/enhancement Improvements or new features and removed kind/bug Some behavior is incorrect or out of spec awaiting-feedback Blocked on input from the author labels Dec 27, 2022
@mikhailshilkov
Copy link
Member

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.

@johnae
Copy link

johnae commented Aug 22, 2023

@mikhailshilkov When using Pulumi YAML this won't work as far as I can tell. I'm fairly new to Pulumi.

@shinebayar-g
Copy link

Can this type mismatch fixed without any type conversion? This was confusing :)

@Chisnet
Copy link

Chisnet commented Jul 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

5 participants