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

powerful-lighter-63321

04/09/2023, 5:26 AM
I've created several networks in a base project (which contains the needed base structure). In another project I wanted to create the needed servers. Now I thought that I can export the network ID (pulumi.iD) in the base project and use it in the other one. But when I try to get the ID in the other project I can't create an IDOutput.
Copy code
subnetId := stackRef.GetOutput(pulumi.String(name)).AsIDOutput()
It ends up with an:
panic: interface conversion: interface {} is string, not pulumi.ID
I've exported it this way:
Copy code
ctx.Export(name, subnet.ID())
The exported ID is something like: 2545501-10.10.1.0/24 As such, it's truely a string. :)
s

salmon-account-74572

04/10/2023, 2:07 PM
Without seeing your code, you should be able to to omit the
.AsIDOutput()
and reference
subnetId
directly as an Input to another resource.
p

powerful-lighter-63321

04/11/2023, 6:27 AM
It doesn't work. The method expects an IDInput and the Output can't be used:
Copy code
subnetId := stackRef.GetOutput(pulumi.String(name))

snet, err := hcloud.GetNetworkSubnet(ctx, ctx.Stack(), subnetId, nil)
It's related to the hcloud and I think if it should be as easy as you describe then there might be something wrong with the hcloud parameters. This would explain that even the examples for hcloud won't work without additional work of casting the Outputs in some other Types.
s

salmon-account-74572

04/11/2023, 12:27 PM
I’m not familiar with the HCloud provider, but I could see where the
GetNetworkSubnet
may not work with an Output for the parameter. Given that this is being retrieved via a stack reference, perhaps check out the new
GetOutputDetails
functionality, which is intended to make it easier to work with values retrieved via stack references: https://www.pulumi.com/blog/stack-reference-output-details/ (I haven’t used this functionality with Go yet, but I have done some work with it in TypeScript.)
p

powerful-lighter-63321

04/12/2023, 7:11 AM
After some tries I got a step further. But: As mentioned in my last post. The one is in Project base, the other is in another Project (not stack). Now It works with the ID as far it gets no issues with getting the ID but the urn isn't found. Which is in another project. What's the master plan? Do I have to have all things together in one Project? WIth diffrent stacks?
s

salmon-account-74572

04/12/2023, 11:41 AM
Can you share more details, perhaps more portions of your code? We’d love to help you find a solution.
3 Views