This message was deleted.
# general
s
This message was deleted.
l
Code with some things I have tried:
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const network1 = new hcloud.Network("network", { ipRange: "10.0.0.0/16" });

//export const networkId = network1.id;
//pulumi.Output.create(network1.id);
//export let network1Exp = network1;
export let network1Exp = network1.id;
Copy code
pulumi stack output --stack org/proj/networks 
Current stack outputs (0): 
   No output values currently in this stack
l
Have you run
pulumi up
?
And you can use
const
rather than
let
, but I don't think that would break it.
l
Yes I ran pulumi up for that stack and tried exporting using those methods that are commented out, each time destroying and recreating the stack. But no luck so far 😞
l
Aside: it is very rarely that you should be importing values into a stack in the same project. Generally that is a sign of a design mistake.
Is this code in index.ts? Exporting from other modules doesn't do what you want.
l
I see, I'm doing it like that because I tried putting everything in the same stack but wasn't working because for example, to create the subnet i had to create first the network. This was messing up previews and I wanted to have everything looking nice and being able to do previews.
l
Have multiple projects.
100 rainbow 1
l
Ok, that is probably the problem, I put things in different files, not in index.ts
l
Other files are other modules. If you export from them, you're exporting from the module, not from the program.
🙏 1
l
Thank you! I got more to experiment with what you said, was stuck in a loop until now.
Will try that, to use different projects. Or maybe separate the stacks in same project but export from index.ts to see what happens.
l
If you're doing different things in different stacks, then you should be using different proejcts.
l
@little-cartoon-10569 I was able to do it thanks to your advise. And even using multiple stacks in a single project. I'm handling each stack like this
if (stack === "networks")
can I tip you with btc? maybe you have a lightning wallet?
l
No tip required, thanks 🙂
It's generally better to prefer multiple projects, than one do-everything project with different code per stack.
Doing it that way makes it difficult to have different target envrionemnts. If you have a stack "network", is that the dev or prod "network"? The Europe or US "network"?
👀 1
You'll end up re-implementing the intended use of stacks via if-statements.
l
Ok thanks for the advise, the reason I'm wanting to do multi stack in one project. It's because its really a single project, but for previews to work, I need to first deploy some stuff so that the IDs are ready and the other stack can read them. And I wanted to use the same folder for this project. But I understand your point, I'm a beginner in this and might switch to what you say later 🙏
👍 1
l
You shouldn't need to deploy something first for the other stack. That's what Pulumi is for. If you need the id from one resource in another resource, then you just pass it in. You don't need to wait for it to be deployed.
🙏 1
l
Okok I will try again later, it might have been something else I was doing wrong. I did too many changes today and my brain is a bit toast.