-
Notifications
You must be signed in to change notification settings - Fork 6
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
cannot use mainNetwork.CustomResourceState.ID() (type pulumi.IDOutput) as type pulumi.IntInput #52
Comments
Same issue with
SDK Version:
|
Same issue with v1.0 and Pulumi v3 sdk. Any workaround or way to fix this? |
Same problem here. I myself are no go-guru, but the following ugly trick seemed to work for now and created some resources successfully. However, it is not elegant this way, so can anyone fix this for good?
|
Hm, I came across this issue today on my first day as a Pulumi employee. Am I correct in saying the reason Here's my (overly verbose) workaround: var conversionCallback = func(val string) (int, error) {
return strconv.Atoi(val)
}
// "droplet" is is struct of type "*digitalocean.Droplet"
// after this line, dropletId is a "pulumi.Int"
var dropletId = droplet.ID().ToStringOutput().ApplyT(conversionCallback).(pulumi.IntOutput) I wonder, should providers offer a package-level conversion function between |
I think I'm running into the same issue with ip, _ := hcloud.NewPrimaryIp(....)
s, _ := hcloud.NewServer(ctx, "server", &hcloud.ServerArgs{
PublicNets: hcloud.ServerPublicNetArray{
&hcloud.ServerPublicNetArgs{
Ipv4Enabled: pulumi.Bool(true),
Ipv4: ip.ID(),
},
},
}
This makes it really difficult to use any of the resources created by the provider as inputs for a later resource. |
The absolute minimum Go code to convert the ID from string to int is (in May 2023): network, err := hcloud.NewNetwork(ctx, "foo", &hcloud.NetworkArgs{
....
_, err = hcloud.NewNetworkSubnet(ctx, "bar", &hcloud.NetworkSubnetArgs{
NetworkId: network.ID().ApplyT(strconv.Atoi).(pulumi.IntOutput),
...
|
This issue is really surprising to new users and even the documented examples are just wrong and don't work out of the box. See the go code in https://www.pulumi.com/registry/packages/hcloud/api-docs/networksubnet/ |
I've for a long time been looking into using Pulumi instead of Terraform, but even before I'm starting, the examples and the provider does not work out of the box. I'm not sure what to make out of this? 🤷🏻♂️ I'm using a banal example from the docs, and that already throws an error: firewall, err := hcloud.NewFirewall(ctx, "myfirewall", &hcloud.FirewallArgs{
Rules: hcloud.FirewallRuleArray{
&hcloud.FirewallRuleArgs{
Direction: pulumi.String("in"),
Protocol: pulumi.String("icmp"),
SourceIps: pulumi.StringArray{
pulumi.String("0.0.0.0/0"),
pulumi.String("::/0"),
},
},
&hcloud.FirewallRuleArgs{
Direction: pulumi.String("in"),
Protocol: pulumi.String("tcp"),
Port: pulumi.String("22"),
SourceIps: pulumi.StringArray{
pulumi.String("0.0.0.0/0"),
pulumi.String("::/0"),
},
},
},
})
...
_, err = hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
Image: pulumi.String("debian-12"),
ServerType: pulumi.String("cx11"),
Location: pulumi.String("hel1"),
FirewallIds: pulumi.IntArray{
firewall.ID(),
},
})
My current take is that I need hacks to make it work, or continue using Terraform to have proper code? |
You can do what the previous poster suggested, |
Broken examples for simple use-cases still do not inspire much confidence which is a pity considering how good pulumi is. |
Is there a way to workaround this issue for the yaml provider? (technically in json. I don't see anything relevant in the builtin fn::s) |
In case it's helpful, just adding another, slightly different use-cased workaround since this is still open.
Then I just call it from main (or anywhere else) with something like: In my case This isn't necessarily my favorite approach, but gets it done for the time being. I'll happily scrap it for something leaner. :) |
Hello,
I have followed the example from Pulumi Documentation (https://www.pulumi.com/docs/reference/pkg/hcloud/networksubnet/) but it looks like that the
hcloud.NewNetworkSubnet
doesn't gets the.ID()
output fromhcloud.NewNetwork
.Expected behavior
Subnet to be created under the right Network CIDR.
Current behaviour
mainNetwork.ID()
output cannot be used asInput
for Subnets.As you can see below if I provide the ID manually using
pulumi.Int(1061706)
it works.Steps to reproduce
Context (Environment)
Affected feature
The text was updated successfully, but these errors were encountered: